@perses-dev/components 0.0.0-snapshot-saving-defaults-refinements-1b25cec → 0.0.0-snapshot-time-chart-rewrite-4667058

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 (307) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.d.ts +1 -1
  2. package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -1
  3. package/dist/ContentWithLegend/ContentWithLegend.js +5 -3
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +10 -4
  6. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  7. package/dist/ContentWithLegend/model/content-with-legend-model.js +27 -8
  8. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  9. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -1
  10. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
  11. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  12. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts +2 -5
  13. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
  14. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  15. package/dist/Drawer/Drawer.js +1 -1
  16. package/dist/Drawer/Drawer.js.map +1 -1
  17. package/dist/EChart/EChart.d.ts +2 -1
  18. package/dist/EChart/EChart.d.ts.map +1 -1
  19. package/dist/EChart/EChart.js +15 -3
  20. package/dist/EChart/EChart.js.map +1 -1
  21. package/dist/GaugeChart/GaugeChart.d.ts +2 -2
  22. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  23. package/dist/GaugeChart/GaugeChart.js +7 -5
  24. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  25. package/dist/Legend/CompactLegend.d.ts +4 -2
  26. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  27. package/dist/Legend/CompactLegend.js +6 -3
  28. package/dist/Legend/CompactLegend.js.map +1 -1
  29. package/dist/Legend/Legend.d.ts +17 -3
  30. package/dist/Legend/Legend.d.ts.map +1 -1
  31. package/dist/Legend/Legend.js +7 -4
  32. package/dist/Legend/Legend.js.map +1 -1
  33. package/dist/Legend/ListLegend.d.ts +4 -2
  34. package/dist/Legend/ListLegend.d.ts.map +1 -1
  35. package/dist/Legend/ListLegend.js +6 -5
  36. package/dist/Legend/ListLegend.js.map +1 -1
  37. package/dist/Legend/ListLegendItem.d.ts +16 -3
  38. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  39. package/dist/Legend/ListLegendItem.js +17 -5
  40. package/dist/Legend/ListLegendItem.js.map +1 -1
  41. package/dist/Legend/TableLegend.d.ts +6 -3
  42. package/dist/Legend/TableLegend.d.ts.map +1 -1
  43. package/dist/Legend/TableLegend.js +17 -3
  44. package/dist/Legend/TableLegend.js.map +1 -1
  45. package/dist/Legend/index.d.ts +1 -0
  46. package/dist/Legend/index.d.ts.map +1 -1
  47. package/dist/Legend/index.js +1 -0
  48. package/dist/Legend/index.js.map +1 -1
  49. package/dist/Legend/legend-model.d.ts +24 -0
  50. package/dist/Legend/legend-model.d.ts.map +1 -0
  51. package/dist/Legend/legend-model.js +19 -0
  52. package/dist/Legend/legend-model.js.map +1 -0
  53. package/dist/LineChart/LineChart.d.ts +6 -11
  54. package/dist/LineChart/LineChart.d.ts.map +1 -1
  55. package/dist/LineChart/LineChart.js +36 -9
  56. package/dist/LineChart/LineChart.js.map +1 -1
  57. package/dist/LineChart/index.d.ts +0 -1
  58. package/dist/LineChart/index.d.ts.map +1 -1
  59. package/dist/LineChart/index.js.map +1 -1
  60. package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  61. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  62. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +12 -0
  63. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts.map +1 -0
  64. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +45 -0
  65. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -0
  66. package/dist/RefreshIntervalPicker/index.d.ts +2 -0
  67. package/dist/RefreshIntervalPicker/index.d.ts.map +1 -0
  68. package/dist/{model/units → RefreshIntervalPicker}/index.js +1 -3
  69. package/dist/RefreshIntervalPicker/index.js.map +1 -0
  70. package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts +36 -0
  71. package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts.map +1 -0
  72. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +65 -0
  73. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -0
  74. package/dist/SettingsAutocomplete/index.d.ts +2 -0
  75. package/dist/SettingsAutocomplete/index.d.ts.map +1 -0
  76. package/dist/{model/units/constants.js → SettingsAutocomplete/index.js} +2 -4
  77. package/dist/SettingsAutocomplete/index.js.map +1 -0
  78. package/dist/StatChart/StatChart.d.ts +3 -2
  79. package/dist/StatChart/StatChart.d.ts.map +1 -1
  80. package/dist/StatChart/StatChart.js +75 -22
  81. package/dist/StatChart/StatChart.js.map +1 -1
  82. package/dist/StatChart/calculateFontSize.d.ts +14 -0
  83. package/dist/StatChart/calculateFontSize.d.ts.map +1 -0
  84. package/dist/StatChart/calculateFontSize.js +47 -0
  85. package/dist/StatChart/calculateFontSize.js.map +1 -0
  86. package/dist/Table/InnerTable.js +3 -3
  87. package/dist/Table/InnerTable.js.map +1 -1
  88. package/dist/Table/Table.d.ts +1 -1
  89. package/dist/Table/Table.d.ts.map +1 -1
  90. package/dist/Table/Table.js +58 -10
  91. package/dist/Table/Table.js.map +1 -1
  92. package/dist/Table/TableCell.d.ts +16 -3
  93. package/dist/Table/TableCell.d.ts.map +1 -1
  94. package/dist/Table/TableCell.js +13 -5
  95. package/dist/Table/TableCell.js.map +1 -1
  96. package/dist/Table/TableCheckbox.js +1 -1
  97. package/dist/Table/TableCheckbox.js.map +1 -1
  98. package/dist/Table/TableHeaderCell.d.ts +23 -0
  99. package/dist/Table/TableHeaderCell.d.ts.map +1 -0
  100. package/dist/Table/TableHeaderCell.js +53 -0
  101. package/dist/Table/TableHeaderCell.js.map +1 -0
  102. package/dist/Table/TableRow.d.ts.map +1 -1
  103. package/dist/Table/TableRow.js +3 -3
  104. package/dist/Table/TableRow.js.map +1 -1
  105. package/dist/Table/VirtualizedTable.d.ts +3 -3
  106. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  107. package/dist/Table/VirtualizedTable.js +51 -10
  108. package/dist/Table/VirtualizedTable.js.map +1 -1
  109. package/dist/Table/model/table-model.d.ts +81 -3
  110. package/dist/Table/model/table-model.d.ts.map +1 -1
  111. package/dist/Table/model/table-model.js +22 -7
  112. package/dist/Table/model/table-model.js.map +1 -1
  113. package/dist/TimeChart/TimeChart.d.ts +23 -0
  114. package/dist/TimeChart/TimeChart.d.ts.map +1 -0
  115. package/dist/TimeChart/TimeChart.js +314 -0
  116. package/dist/TimeChart/TimeChart.js.map +1 -0
  117. package/dist/TimeChart/index.d.ts +2 -0
  118. package/dist/TimeChart/index.d.ts.map +1 -0
  119. package/dist/{LegendOptionsEditor → TimeChart}/index.js +1 -1
  120. package/dist/TimeChart/index.js.map +1 -0
  121. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.d.ts → LineChartTooltip.d.ts} +5 -4
  122. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -0
  123. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +7 -6
  124. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -0
  125. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +16 -0
  126. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -0
  127. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +76 -0
  128. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -0
  129. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +2 -2
  130. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
  131. package/dist/TimeSeriesTooltip/TooltipHeader.js +10 -8
  132. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  133. package/dist/TimeSeriesTooltip/index.d.ts +2 -1
  134. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  135. package/dist/TimeSeriesTooltip/index.js +2 -1
  136. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  137. package/dist/TimeSeriesTooltip/nearby-series.d.ts +23 -4
  138. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  139. package/dist/TimeSeriesTooltip/nearby-series.js +175 -17
  140. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
  142. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  143. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  144. package/dist/TimeSeriesTooltip/utils.d.ts +25 -0
  145. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  146. package/dist/TimeSeriesTooltip/utils.js +29 -1
  147. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  148. package/dist/UnitSelector/UnitSelector.d.ts +1 -1
  149. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
  150. package/dist/UnitSelector/UnitSelector.js +11 -24
  151. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  152. package/dist/YAxisLabel.js +1 -1
  153. package/dist/YAxisLabel.js.map +1 -1
  154. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +5 -3
  155. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +28 -9
  156. package/dist/cjs/Drawer/Drawer.js +1 -1
  157. package/dist/cjs/EChart/EChart.js +22 -5
  158. package/dist/cjs/GaugeChart/GaugeChart.js +7 -5
  159. package/dist/cjs/Legend/CompactLegend.js +7 -4
  160. package/dist/cjs/Legend/Legend.js +8 -5
  161. package/dist/cjs/Legend/ListLegend.js +7 -6
  162. package/dist/cjs/Legend/ListLegendItem.js +17 -5
  163. package/dist/cjs/Legend/TableLegend.js +17 -3
  164. package/dist/cjs/Legend/index.js +1 -0
  165. package/dist/cjs/{model/units/types.js → Legend/legend-model.js} +7 -10
  166. package/dist/cjs/LineChart/LineChart.js +35 -47
  167. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  168. package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +51 -0
  169. package/dist/cjs/{model/units → RefreshIntervalPicker}/index.js +1 -3
  170. package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +66 -0
  171. package/dist/cjs/SettingsAutocomplete/index.js +28 -0
  172. package/dist/cjs/StatChart/StatChart.js +82 -24
  173. package/dist/cjs/StatChart/calculateFontSize.js +51 -0
  174. package/dist/cjs/Table/InnerTable.js +3 -3
  175. package/dist/cjs/Table/Table.js +57 -9
  176. package/dist/cjs/Table/TableCell.js +13 -5
  177. package/dist/cjs/Table/TableCheckbox.js +1 -1
  178. package/dist/cjs/Table/TableHeaderCell.js +59 -0
  179. package/dist/cjs/Table/TableRow.js +2 -2
  180. package/dist/cjs/Table/VirtualizedTable.js +51 -10
  181. package/dist/cjs/Table/model/table-model.js +22 -7
  182. package/dist/cjs/TimeChart/TimeChart.js +320 -0
  183. package/dist/cjs/{LegendOptionsEditor → TimeChart}/index.js +1 -1
  184. package/dist/cjs/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +7 -45
  185. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +87 -0
  186. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +10 -8
  187. package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
  188. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +171 -17
  189. package/dist/cjs/TimeSeriesTooltip/utils.js +35 -3
  190. package/dist/cjs/UnitSelector/UnitSelector.js +15 -28
  191. package/dist/cjs/YAxisLabel.js +1 -1
  192. package/dist/cjs/index.js +3 -1
  193. package/dist/cjs/model/index.js +1 -2
  194. package/dist/cjs/model/timeOption.js +16 -0
  195. package/dist/cjs/{model/units/constants.js → theme/component-overrides/paper.js} +9 -5
  196. package/dist/cjs/theme/palette/background.js +2 -2
  197. package/dist/cjs/theme/theme.js +2 -0
  198. package/dist/cjs/utils/axis.js +58 -0
  199. package/dist/cjs/{LineChart/utils.js → utils/chart-actions.js} +9 -47
  200. package/dist/cjs/utils/format.js +47 -1
  201. package/dist/cjs/utils/index.js +3 -1
  202. package/dist/cjs/utils/theme-gen.js +44 -2
  203. package/dist/index.d.ts +3 -1
  204. package/dist/index.d.ts.map +1 -1
  205. package/dist/index.js +3 -1
  206. package/dist/index.js.map +1 -1
  207. package/dist/model/graph.d.ts +20 -3
  208. package/dist/model/graph.d.ts.map +1 -1
  209. package/dist/model/graph.js.map +1 -1
  210. package/dist/model/index.d.ts +1 -2
  211. package/dist/model/index.d.ts.map +1 -1
  212. package/dist/model/index.js +1 -2
  213. package/dist/model/index.js.map +1 -1
  214. package/dist/model/theme.d.ts +4 -6
  215. package/dist/model/theme.d.ts.map +1 -1
  216. package/dist/model/theme.js.map +1 -1
  217. package/dist/model/timeOption.d.ts +6 -0
  218. package/dist/model/timeOption.d.ts.map +1 -0
  219. package/dist/model/{units/types.js → timeOption.js} +2 -9
  220. package/dist/model/timeOption.js.map +1 -0
  221. package/dist/theme/component-overrides/paper.d.ts +3 -0
  222. package/dist/theme/component-overrides/paper.d.ts.map +1 -0
  223. package/dist/theme/component-overrides/paper.js +21 -0
  224. package/dist/theme/component-overrides/paper.js.map +1 -0
  225. package/dist/theme/palette/background.js +2 -2
  226. package/dist/theme/palette/background.js.map +1 -1
  227. package/dist/theme/theme.d.ts.map +1 -1
  228. package/dist/theme/theme.js +2 -0
  229. package/dist/theme/theme.js.map +1 -1
  230. package/dist/utils/axis.d.ts +14 -0
  231. package/dist/utils/axis.d.ts.map +1 -0
  232. package/dist/utils/axis.js +45 -0
  233. package/dist/utils/axis.js.map +1 -0
  234. package/dist/utils/chart-actions.d.ts +18 -0
  235. package/dist/utils/chart-actions.d.ts.map +1 -0
  236. package/dist/utils/chart-actions.js +52 -0
  237. package/dist/utils/chart-actions.js.map +1 -0
  238. package/dist/utils/format.d.ts +6 -0
  239. package/dist/utils/format.d.ts.map +1 -1
  240. package/dist/utils/format.js +47 -0
  241. package/dist/utils/format.js.map +1 -1
  242. package/dist/utils/index.d.ts +3 -1
  243. package/dist/utils/index.d.ts.map +1 -1
  244. package/dist/utils/index.js +3 -1
  245. package/dist/utils/index.js.map +1 -1
  246. package/dist/utils/theme-gen.d.ts.map +1 -1
  247. package/dist/utils/theme-gen.js +38 -1
  248. package/dist/utils/theme-gen.js.map +1 -1
  249. package/package.json +5 -9
  250. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts +0 -8
  251. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +0 -1
  252. package/dist/LegendOptionsEditor/LegendOptionsEditor.js +0 -109
  253. package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +0 -1
  254. package/dist/LegendOptionsEditor/index.d.ts +0 -2
  255. package/dist/LegendOptionsEditor/index.d.ts.map +0 -1
  256. package/dist/LegendOptionsEditor/index.js.map +0 -1
  257. package/dist/LineChart/utils.d.ts +0 -30
  258. package/dist/LineChart/utils.d.ts.map +0 -1
  259. package/dist/LineChart/utils.js +0 -90
  260. package/dist/LineChart/utils.js.map +0 -1
  261. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +0 -1
  262. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +0 -1
  263. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +0 -115
  264. package/dist/cjs/model/legend.js +0 -102
  265. package/dist/cjs/model/units/bytes.js +0 -84
  266. package/dist/cjs/model/units/decimal.js +0 -62
  267. package/dist/cjs/model/units/percent.js +0 -73
  268. package/dist/cjs/model/units/time.js +0 -105
  269. package/dist/cjs/model/units/units.js +0 -101
  270. package/dist/cjs/model/units/utils.js +0 -42
  271. package/dist/model/legend.d.ts +0 -36
  272. package/dist/model/legend.d.ts.map +0 -1
  273. package/dist/model/legend.js +0 -81
  274. package/dist/model/legend.js.map +0 -1
  275. package/dist/model/units/bytes.d.ts +0 -13
  276. package/dist/model/units/bytes.d.ts.map +0 -1
  277. package/dist/model/units/bytes.js +0 -66
  278. package/dist/model/units/bytes.js.map +0 -1
  279. package/dist/model/units/constants.d.ts +0 -2
  280. package/dist/model/units/constants.d.ts.map +0 -1
  281. package/dist/model/units/constants.js.map +0 -1
  282. package/dist/model/units/decimal.d.ts +0 -13
  283. package/dist/model/units/decimal.d.ts.map +0 -1
  284. package/dist/model/units/decimal.js +0 -49
  285. package/dist/model/units/decimal.js.map +0 -1
  286. package/dist/model/units/index.d.ts +0 -4
  287. package/dist/model/units/index.d.ts.map +0 -1
  288. package/dist/model/units/index.js.map +0 -1
  289. package/dist/model/units/percent.d.ts +0 -12
  290. package/dist/model/units/percent.d.ts.map +0 -1
  291. package/dist/model/units/percent.js +0 -60
  292. package/dist/model/units/percent.js.map +0 -1
  293. package/dist/model/units/time.d.ts +0 -22
  294. package/dist/model/units/time.d.ts.map +0 -1
  295. package/dist/model/units/time.js +0 -91
  296. package/dist/model/units/time.js.map +0 -1
  297. package/dist/model/units/types.d.ts +0 -47
  298. package/dist/model/units/types.d.ts.map +0 -1
  299. package/dist/model/units/types.js.map +0 -1
  300. package/dist/model/units/units.d.ts +0 -40
  301. package/dist/model/units/units.d.ts.map +0 -1
  302. package/dist/model/units/units.js +0 -80
  303. package/dist/model/units/units.js.map +0 -1
  304. package/dist/model/units/utils.d.ts +0 -4
  305. package/dist/model/units/utils.d.ts.map +0 -1
  306. package/dist/model/units/utils.js +0 -32
  307. package/dist/model/units/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2023 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 { useDeepMemo } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\nexport interface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined || data.value === null) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, unit, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter: (value: number) => {\n return formatValue(value, unit);\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(value: number, unit: UnitOptions, width: number, height: number) {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = formatValue(value, unit);\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","unit","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,WAAW,QAAQ,kBAAkB,CAAC;AAC/C,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,UAAU,IAAIC,iBAAiB,QAA2B,gBAAgB,CAAC;AACpF,SAASC,aAAa,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,oBAAoB,CAAC;AACrF,SAASC,cAAc,Q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ensed 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 { formatValue, useDeepMemo, UnitOptions } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\nexport interface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, unit, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter:\n data.value === null\n ? // We use a different function when we *know* the value is null\n // at this level because the `formatter` function argument is `NaN`\n // when the value is `null`, making it difficult to differentiate\n // `null` from a true `NaN` case.\n () => 'null'\n : (value: number) => {\n return formatValue(value, unit);\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(value: number | null, unit: UnitOptions, width: number, height: number) {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = typeof value === 'number' ? formatValue(value, unit) : `${value}`;\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["formatValue","useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","unit","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,WAAW,EAAEC,WAAW,QAAqB,kBAAkB,CAAC;AACzE,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,UAAU,IAAIC,iBAAiB,QAA2B,gB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C,MAAM,EAAEF,QAAQ,CAAC,IAAI,EAAEK,SAAS,CAAC,IAAI,EAAEJ,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC/D,CAAC"}
@@ -1,11 +1,13 @@
1
1
  /// <reference types="react" />
2
- import { LegendItem, SelectedLegendItemState } from '../model';
3
2
  import { ListLegendItemProps } from './ListLegendItem';
3
+ import { LegendItem, SelectedLegendItemState } from './legend-model';
4
4
  export interface CompactLegendProps {
5
5
  height: number;
6
6
  items: LegendItem[];
7
7
  selectedItems: SelectedLegendItemState;
8
8
  onLegendItemClick: ListLegendItemProps['onClick'];
9
+ onItemMouseOver: ListLegendItemProps['onMouseOver'];
10
+ onItemMouseOut: ListLegendItemProps['onMouseOut'];
9
11
  }
10
12
  /**
11
13
  * CompactLegend is default and used when legend items need to show side by side
@@ -13,5 +15,5 @@ export interface CompactLegendProps {
13
15
  * number of items. The `ListLegend` is used for cases with large numbers of items
14
16
  * because it is virtualized.
15
17
  */
16
- export declare function CompactLegend({ height, items, selectedItems, onLegendItemClick }: CompactLegendProps): JSX.Element;
18
+ export declare function CompactLegend({ height, items, selectedItems, onLegendItemClick, onItemMouseOver, onItemMouseOut, }: CompactLegendProps): JSX.Element;
17
19
  //# sourceMappingURL=CompactLegend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompactLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/CompactLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,kBAAkB,eAkBpG"}
1
+ {"version":3,"file":"CompactLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/CompactLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,gBAAgB,CAAC;AAEnG,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAClD,eAAe,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACpD,cAAc,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,EAAE,kBAAkB,eAqBpB"}
@@ -12,14 +12,14 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
- import { isLegendItemVisuallySelected } from '../model';
16
15
  import { ListLegendItem } from './ListLegendItem';
16
+ import { isLegendItemVisuallySelected } from './legend-model';
17
17
  /**
18
18
  * CompactLegend is default and used when legend items need to show side by side
19
19
  * which corresponds to when legend.position is `bottom` with a relatively small
20
20
  * number of items. The `ListLegend` is used for cases with large numbers of items
21
21
  * because it is virtualized.
22
- */ export function CompactLegend({ height , items , selectedItems , onLegendItemClick }) {
22
+ */ export function CompactLegend({ height , items , selectedItems , onLegendItemClick , onItemMouseOver , onItemMouseOut }) {
23
23
  return /*#__PURE__*/ _jsx(Box, {
24
24
  component: "ul",
25
25
  sx: {
@@ -34,9 +34,12 @@ import { ListLegendItem } from './ListLegendItem';
34
34
  overflowY: 'scroll',
35
35
  margin: 0
36
36
  },
37
- children: items.map((item)=>/*#__PURE__*/ _jsx(ListLegendItem, {
37
+ children: items.map((item, index)=>/*#__PURE__*/ _jsx(ListLegendItem, {
38
38
  item: item,
39
+ index: index,
39
40
  isVisuallySelected: isLegendItemVisuallySelected(item, selectedItems),
41
+ onMouseOver: onItemMouseOver,
42
+ onMouseOut: onItemMouseOut,
40
43
  onClick: onLegendItemClick,
41
44
  sx: {
42
45
  width: 'auto',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/CompactLegend.tsx"],"sourcesContent":["// Copyright 2023 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 { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from '../model';\nimport { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\n\nexport interface CompactLegendProps {\n height: number;\n items: LegendItem[];\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n}\n\n/**\n * CompactLegend is default and used when legend items need to show side by side\n * which corresponds to when legend.position is `bottom` with a relatively small\n * number of items. The `ListLegend` is used for cases with large numbers of items\n * because it is virtualized.\n */\nexport function CompactLegend({ height, items, selectedItems, onLegendItemClick }: CompactLegendProps) {\n return (\n <Box component=\"ul\" sx={{ width: '100%', height, padding: [0, 1, 0, 0], overflowY: 'scroll', margin: 0 }}>\n {items.map((item) => (\n <ListLegendItem\n key={item.id}\n item={item}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n sx={{\n width: 'auto',\n float: 'left',\n paddingRight: 1.5,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","isLegendItemVisuallySelected","ListLegendItem","CompactLegend","height","items","selectedItems","onLegendItemClick","component","sx","width","padding","overflowY","margin","map","item","isVisuallySelected","onClick","float","paddingRight","id"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAA8CC,4BAA4B,QAAQ,UAAU,CAAC;AAC7F,SAASC,cAAc,QAA6B,kBAAkB,CAAC;AASvE;;;;;CAKC,GACD,OAAO,SAASC,aAAa,CAAC,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAEC,aAAa,CAAA,EAAEC,iBAAiB,CAAA,EAAsB,EAAE;IACrG,qBACE,KAACP,GAAG;QAACQ,SAAS,EAAC,IAAI;QAACC,EAAE,EAAE;YAAEC,KAAK,EAAE,MAAM;YAAEN,MAAM;YAAEO,OAAO,EAAE;AAAC,iBAAC;AAAE,iBAAC;AAAE,iBAAC;AAAE,iBAAC;aAAC;YAAEC,SAAS,EAAE,QAAQ;YAAEC,MAAM,EAAE,CAAC;SAAE;kBACrGR,KAAK,CAACS,GAAG,CAAC,CAACC,IAAI,iBACd,KAACb,cAAc;gBAEba,IAAI,EAAEA,IAAI;gBACVC,kBAAkB,EAAEf,4BAA4B,CAACc,IAAI,EAAET,aAAa,CAAC;gBACrEW,OAAO,EAAEV,iBAAiB;gBAC1BE,EAAE,EAAE;oBACFC,KAAK,EAAE,MAAM;oBACbQ,KAAK,EAAE,MAAM;oBACbC,YAAY,EAAE,GAAG;iBAClB;eARIJ,IAAI,CAACK,EAAE,CASZ,AACH,CAAC;MACE,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/CompactLegend.tsx"],"sourcesContent":["// Copyright 2023 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 { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\nimport { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from './legend-model';\n\nexport interface CompactLegendProps {\n height: number;\n items: LegendItem[];\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n onItemMouseOver: ListLegendItemProps['onMouseOver'];\n onItemMouseOut: ListLegendItemProps['onMouseOut'];\n}\n\n/**\n * CompactLegend is default and used when legend items need to show side by side\n * which corresponds to when legend.position is `bottom` with a relatively small\n * number of items. The `ListLegend` is used for cases with large numbers of items\n * because it is virtualized.\n */\nexport function CompactLegend({\n height,\n items,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n}: CompactLegendProps) {\n return (\n <Box component=\"ul\" sx={{ width: '100%', height, padding: [0, 1, 0, 0], overflowY: 'scroll', margin: 0 }}>\n {items.map((item, index) => (\n <ListLegendItem\n key={item.id}\n item={item}\n index={index}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onMouseOver={onItemMouseOver}\n onMouseOut={onItemMouseOut}\n onClick={onLegendItemClick}\n sx={{\n width: 'auto',\n float: 'left',\n paddingRight: 1.5,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ListLegendItem","isLegendItemVisuallySelected","CompactLegend","height","items","selectedItems","onLegendItemClick","onItemMouseOver","onItemMouseOut","component","sx","width","padding","overflowY","margin","map","item","index","isVisuallySel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@@
1
1
  /// <reference types="react" />
2
- import { LegendOptions, LegendItem, SelectedLegendItemState } from '../model';
2
+ import { TableLegendProps } from './TableLegend';
3
+ import { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';
4
+ import { ListLegendItemProps } from './ListLegendItem';
3
5
  export interface LegendProps {
4
6
  width: number;
5
7
  height: number;
6
8
  data: LegendItem[];
7
- options: LegendOptions;
9
+ options: LegendComponentOptions;
8
10
  /**
9
11
  * State of selected items in the legend.
10
12
  *
@@ -16,6 +18,18 @@ export interface LegendProps {
16
18
  * Callback fired when the selected items in the legend changes.
17
19
  */
18
20
  onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;
21
+ /**
22
+ * Callback fired when the mouse is moved over a legend item.
23
+ */
24
+ onItemMouseOver?: ListLegendItemProps['onMouseOver'];
25
+ /**
26
+ * Callback fired when the mouse is moved out of a legend item.
27
+ */
28
+ onItemMouseOut?: ListLegendItemProps['onMouseOut'];
29
+ /**
30
+ * Props specific to legend with `mode` set to `table`.
31
+ */
32
+ tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;
19
33
  }
20
- export declare function Legend({ width, height, options, data, selectedItems, onSelectedItemsChange }: LegendProps): JSX.Element;
34
+ export declare function Legend({ width, height, options, data, selectedItems, onSelectedItemsChange, onItemMouseOver, onItemMouseOut, tableProps, }: LegendProps): JSX.Element;
21
35
  //# sourceMappingURL=Legend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,uBAAuB,EAAiB,MAAM,UAAU,CAAC;AAK7F,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IAEvB;;;;;OAKG;IACH,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"react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { produce } from 'immer';
16
- import { getLegendMode } from '../model';
16
+ import { getLegendMode } from '@perses-dev/core';
17
17
  import { ListLegend } from './ListLegend';
18
18
  import { CompactLegend } from './CompactLegend';
19
19
  import { TableLegend } from './TableLegend';
@@ -23,7 +23,7 @@ import { TableLegend } from './TableLegend';
23
23
  // Set this number based on testing, but it may need to be tuned a bit on the
24
24
  // future as people test this out on different machines.
25
25
  const NEED_VIRTUALIZATION_LIMIT = 500;
26
- export function Legend({ width , height , options , data , selectedItems , onSelectedItemsChange }) {
26
+ export function Legend({ width , height , options , data , selectedItems , onSelectedItemsChange , onItemMouseOver , onItemMouseOut , tableProps }) {
27
27
  const onLegendItemClick = (e, seriesId)=>{
28
28
  const isModifiedClick = e.metaKey || e.shiftKey;
29
29
  const newSelected = produce(selectedItems, (draft)=>{
@@ -66,14 +66,17 @@ export function Legend({ width , height , options , data , selectedItems , onSel
66
66
  height,
67
67
  items: data,
68
68
  selectedItems,
69
- onLegendItemClick
69
+ onLegendItemClick,
70
+ onItemMouseOver,
71
+ onItemMouseOut
70
72
  };
71
73
  let legendContent;
72
74
  if (mode === 'Table') {
73
75
  legendContent = /*#__PURE__*/ _jsx(TableLegend, {
74
76
  ...commonLegendProps,
75
77
  onSelectedItemsChange: onSelectedItemsChange,
76
- width: width
78
+ width: width,
79
+ ...tableProps
77
80
  });
78
81
  } else if (options.position === 'Right' || needsVirtualization) {
79
82
  legendContent = /*#__PURE__*/ _jsx(ListLegend, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/Legend.tsx"],"sourcesContent":["// Copyright 2023 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 { produce } from 'immer';\nimport { ReactNode } from 'react';\nimport { LegendOptions, LegendItem, SelectedLegendItemState, getLegendMode } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\nimport { TableLegend } from './TableLegend';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({ width, height, options, data, selectedItems, onSelectedItemsChange }: LegendProps) {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n };\n\n let legendContent: ReactNode;\n if (mode === 'Table') {\n legendContent = <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} />;\n } else if (options.position === 'Right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'Right') {\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n top: 0,\n right: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n bottom: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","ListLegend","CompactLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT","Legend","width","height","options","data","selectedItems","onSelectedItemsChange","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","sx","top","right","bottom"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,OAAO,QAAQ,OAAO,CAAC;AAEhC,SAA6DC,aAAa,QAAQ,UAAU,CAAC;AAC7F,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAChD,SAASC,WAAW,QAAQ,eAAe,CA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Aa;MACV,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/Legend.tsx"],"sourcesContent":["// Copyright 2023 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 { produce } from 'immer';\nimport { ReactNode } from 'react';\nimport { getLegendMode } from '@perses-dev/core';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\nimport { TableLegend, TableLegendProps } from './TableLegend';\nimport { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';\nimport { ListLegendItemProps } from './ListLegendItem';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendComponentOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n\n /**\n * Callback fired when the mouse is moved over a legend item.\n */\n onItemMouseOver?: ListLegendItemProps['onMouseOver'];\n\n /**\n * Callback fired when the mouse is moved out of a legend item.\n */\n onItemMouseOut?: ListLegendItemProps['onMouseOut'];\n\n /**\n * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({\n width,\n height,\n options,\n data,\n selectedItems,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n tableProps,\n}: LegendProps) {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n };\n\n let legendContent: ReactNode;\n if (mode === 'Table') {\n legendContent = (\n <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} {...tableProps} />\n );\n } else if (options.position === 'Right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'Right') {\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n top: 0,\n right: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n bottom: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","ListLegend","CompactLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT","Legend","width","height","options","data","selectedItems","onSelectedItemsChange","onItemMouseOver","onItemMouseOut","tableProps","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","sx","top","right","bottom"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,OAAO,QAAQ,OAAO,CAAC;AAEhC,SAASC,aAAa,QAAQ,kBAAkB,CAAC;AACjD,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAChD,SAASC,WAAW,QAA0B,eAAe,CAAC;AAuC9D,4EAA4E;AAC5E,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,wDAAwD;AACxD,MAAMC,yBAAyB,GAAG,GAAG,AAAC;AAEtC,OAAO,SAASC,MAAM,CAAC,EACrBC,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,OAAO,CAAA,EACPC,IAAI,CAAA,EACJC,aAAa,CAAA,EACbC,qBAAqB,CAAA,EACrBC,eAAe,CAAA,EACfC,cAAc,CAAA,EACdC,UAAU,CAAA,EACE,EAAE;IACd,MAAMC,iBAAiB,GAAG,CAACC,CAA4C,EAAEC,QAAgB,GAAK;QAC5F,MAAMC,eAAe,GAAGF,CAAC,CAACG,OAAO,IAAIH,CAAC,CAACI,QAAQ,AAAC;QAEhD,MAAMC,WAAW,GAAGtB,OAAO,CAACW,aA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KAAK;YAAG,GAAGQ,UAAU;UAAI,AACnH,CAAC;IACJ,OAAO,IAAIN,OAAO,CAACsB,QAAQ,KAAK,OAAO,IAAIL,mBAAmB,EAAE;QAC9DI,aAAa,iBAAG,KAAC5B,UAAU;YAAE,GAAG0B,iBAAiB;YAAErB,KAAK,EAAEA,KAAK;YAAES,iBAAiB,EAAEA,iBAAiB;UAAI,CAAC;IAC5G,OAAO;QACLc,aAAa,iBAAG,KAAC3B,aAAa;YAAE,GAAGyB,iBAAiB;YAAEZ,iBAAiB,EAAEA,iBAAiB;UAAI,CAAC;IACjG,CAAC;IAED,IAAIP,OAAO,CAACsB,QAAQ,KAAK,OAAO,EAAE;QAChC,qBACE,KAAChC,GAAG;YACFiC,EAAE,EAAE;gBACFzB,KAAK,EAAEA,KAAK;gBACZC,MAAM,EAAEA,MAAM;gBACduB,QAAQ,EAAE,UAAU;gBACpBE,GAAG,EAAE,CAAC;gBACNC,KAAK,EAAE,CAAC;aACT;sBAEAJ,aAAa;UACV,CACN;IACJ,CAAC;IAED,kBAAkB;IAClB,qBACE,KAAC/B,GAAG;QACFiC,EAAE,EAAE;YACFzB,KAAK,EAAEA,KAAK;YACZC,MAAM,EAAEA,MAAM;YACduB,QAAQ,EAAE,UAAU;YACpBI,MAAM,EAAE,CAAC;SACV;kBAEAL,aAAa;MACV,CACN;AACJ,CAAC"}
@@ -1,12 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { LegendItem, SelectedLegendItemState } from '../model';
3
2
  import { ListLegendItemProps } from './ListLegendItem';
3
+ import { LegendItem, SelectedLegendItemState } from './legend-model';
4
4
  export interface ListLegendProps {
5
5
  items: LegendItem[];
6
6
  height: number;
7
7
  width: number;
8
8
  selectedItems: SelectedLegendItemState;
9
9
  onLegendItemClick: ListLegendItemProps['onClick'];
10
+ onItemMouseOver: ListLegendItemProps['onMouseOver'];
11
+ onItemMouseOut: ListLegendItemProps['onMouseOut'];
10
12
  }
11
13
  /**
12
14
  * ListLegend is used when legend.position is 'right' since legend items are
@@ -14,5 +16,5 @@ export interface ListLegendProps {
14
16
  * large number of items because it is virtualized and easier to visually scan
15
17
  * large numbers of items when there is a single item per row.
16
18
  */
17
- export declare function ListLegend({ items, height, width, selectedItems, onLegendItemClick }: ListLegendProps): JSX.Element;
19
+ export declare function ListLegend({ items, height, width, selectedItems, onLegendItemClick, onItemMouseOver, onItemMouseOut, }: ListLegendProps): JSX.Element;
18
20
  //# sourceMappingURL=ListLegend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,eAAe,eA6BrG"}
1
+ {"version":3,"file":"ListLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,gBAAgB,CAAC;AAEnG,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAClD,eAAe,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACpD,cAAc,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,MAAM,EACN,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,EAAE,eAAe,eA8BjB"}
@@ -12,14 +12,14 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Virtuoso } from 'react-virtuoso';
15
- import { isLegendItemVisuallySelected } from '../model';
16
15
  import { ListLegendItem } from './ListLegendItem';
16
+ import { isLegendItemVisuallySelected } from './legend-model';
17
17
  /**
18
18
  * ListLegend is used when legend.position is 'right' since legend items are
19
19
  * stacked. It is also used for `bottom` positioned legends when there are a
20
20
  * large number of items because it is virtualized and easier to visually scan
21
21
  * large numbers of items when there is a single item per row.
22
- */ export function ListLegend({ items , height , width , selectedItems , onLegendItemClick }) {
22
+ */ export function ListLegend({ items , height , width , selectedItems , onLegendItemClick , onItemMouseOver , onItemMouseOut }) {
23
23
  // show full labels on hover when there are many total series
24
24
  const truncateLabels = items.length > 5;
25
25
  return /*#__PURE__*/ _jsx(Virtuoso, {
@@ -31,13 +31,14 @@ import { ListLegendItem } from './ListLegendItem';
31
31
  itemContent: (index, item)=>{
32
32
  return /*#__PURE__*/ _jsx(ListLegendItem, {
33
33
  item: item,
34
+ index: index,
34
35
  truncateLabel: truncateLabels,
35
36
  isVisuallySelected: isLegendItemVisuallySelected(item, selectedItems),
36
37
  onClick: onLegendItemClick,
38
+ onMouseOver: onItemMouseOver,
39
+ onMouseOut: onItemMouseOut,
37
40
  sx: {
38
- // Having an explicit width is important for the ellipsizing to
39
- // work correctly. Subtract padding to simulate padding.
40
- width: width,
41
+ width: '100%',
41
42
  wordBreak: 'break-word',
42
43
  overflow: 'hidden'
43
44
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/ListLegend.tsx"],"sourcesContent":["// Copyright 2023 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 { Virtuoso } from 'react-virtuoso';\nimport { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from '../model';\nimport { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\n\nexport interface ListLegendProps {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n}\n\n/**\n * ListLegend is used when legend.position is 'right' since legend items are\n * stacked. It is also used for `bottom` positioned legends when there are a\n * large number of items because it is virtualized and easier to visually scan\n * large numbers of items when there is a single item per row.\n */\nexport function ListLegend({ items, height, width, selectedItems, onLegendItemClick }: ListLegendProps) {\n // show full labels on hover when there are many total series\n const truncateLabels = items.length > 5;\n\n return (\n <Virtuoso\n style={{ height, width }}\n data={items}\n itemContent={(index, item) => {\n return (\n <ListLegendItem\n key={item.id}\n item={item}\n truncateLabel={truncateLabels}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n sx={{\n // Having an explicit width is important for the ellipsizing to\n // work correctly. Subtract padding to simulate padding.\n width: width,\n wordBreak: 'break-word',\n overflow: 'hidden',\n }}\n />\n );\n }}\n role=\"list\"\n />\n );\n}\n"],"names":["Virtuoso","isLegendItemVisuallySelected","ListLegendItem","ListLegend","items","height","width","selectedItems","onLegendItemClick","truncateLabels","length","style","data","itemContent","index","item","truncateLabel","isVisuallySelected","onClick","sx","wordBreak","overflow","id","role"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,gBAAgB,CAAC;AAC1C,SAA8CC,4BAA4B,QAAQ,UAAU,CAAC;AAC7F,SAASC,cAAc,QAA6B,kBAAkB,CAAC;AAUvE;;;;;CAKC,GACD,OAAO,SAASC,UAAU,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAEC,aAAa,CAAA,EAAEC,iBAAiB,CAAA,EAAmB,EAAE;IACtG,6DAA6D;IAC7D,MAAMC,cAAc,GAAGL,KAAK,CAACM,MAAM,GAAG,CAAC,AAAC;IAExC,qBACE,KAACV,QAAQ;QACPW,KAAK,EAAE;YAAEN,MAAM;YAAEC,KAAK;SAAE;QACxBM,IAAI,EAAER,KAAK;QACXS,WAAW,EAAE,CAACC,KAAK,EAAEC,IAAI,GAAK;YAC5B,qBACE,KAACb,cAAc;gBAEba,IAAI,EAAEA,IAAI;gBACVC,aAAa,EAAEP,cAAc;gBAC7BQ,kBAAkB,EAAEhB,4BAA4B,CAACc,IAAI,EAAER,aAAa,CAAC;gBACrEW,OAAO,EAAEV,iBAAiB;gBAC1BW,EAAE,EAAE;oBACF,+DAA+D;oBAC/D,wDAAwD;oBACxDb,KAAK,EAAEA,KAAK;oBACZc,SAAS,EAAE,YAAY;oBACvBC,QAAQ,EAAE,QAAQ;iBACnB;eAXIN,IAAI,CAACO,EAAE,CAYZ,CACF;QACJ,CAAC;QACDC,IAAI,EAAC,MAAM;MACX,CACF;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/ListLegend.tsx"],"sourcesContent":["// Copyright 2023 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 { Virtuoso } from 'react-virtuoso';\nimport { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\nimport { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from './legend-model';\n\nexport interface ListLegendProps {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n onItemMouseOver: ListLegendItemProps['onMouseOver'];\n onItemMouseOut: ListLegendItemProps['onMouseOut'];\n}\n\n/**\n * ListLegend is used when legend.position is 'right' since legend items are\n * stacked. It is also used for `bottom` positioned legends when there are a\n * large number of items because it is virtualized and easier to visually scan\n * large numbers of items when there is a single item per row.\n */\nexport function ListLegend({\n items,\n height,\n width,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n}: ListLegendProps) {\n // show full labels on hover when there are many total series\n const truncateLabels = items.length > 5;\n\n return (\n <Virtuoso\n style={{ height, width }}\n data={items}\n itemContent={(index, item) => {\n return (\n <ListLegendItem\n key={item.id}\n item={item}\n index={index}\n truncateLabel={truncateLabels}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n onMouseOver={onItemMouseOver}\n onMouseOut={onItemMouseOut}\n sx={{\n width: '100%',\n wordBreak: 'break-word',\n overflow: 'hidden',\n }}\n />\n );\n }}\n role=\"list\"\n />\n );\n}\n"],"names":["Virtuoso","ListLegendItem","isLegendItemVisuallySelected","ListLegend","items","height","width","selectedItems","onLegendItemClick","onItemMouseOver","onItemMouseOut","truncateLabels","length","style","data","itemContent","index","item","truncateLabel","isVisuallySelected","onClick","onMouseOver","onMouseOut","sx","wordBreak","overflow","id","role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1
1
  import React from 'react';
2
2
  import { ListItemProps } from '@mui/material';
3
- import { LegendItem } from '../model';
4
- export interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick'> {
3
+ import { LegendItem } from './legend-model';
4
+ export declare type LegendItemEventOpts = {
5
+ /**
6
+ * Unique identifier for the legend item.
7
+ */
8
+ id: string;
9
+ /**
10
+ * Index of the row in the original data.
11
+ */
12
+ index: number;
13
+ };
14
+ export interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick' | 'onMouseOver' | 'onMouseOut'> {
5
15
  item: LegendItem;
16
+ index: number;
6
17
  /**
7
18
  * When true, the item is rendered differently to visually communicate it is
8
19
  * selected.
9
20
  */
10
21
  isVisuallySelected?: boolean;
11
22
  onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => void;
23
+ onMouseOver?: (e: React.MouseEvent, opts: LegendItemEventOpts) => void;
24
+ onMouseOut?: (e: React.MouseEvent, opts: LegendItemEventOpts) => void;
12
25
  /**
13
26
  * When `true`, will keep labels to a single line with overflow ellipsized. The
14
27
  * full content will be shown on hover.
@@ -17,5 +30,5 @@ export interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick
17
30
  */
18
31
  truncateLabel?: boolean;
19
32
  }
20
- export declare const ListLegendItem: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<ListLegendItemProps, "classes" | "className" | "style" | "children" | "sx" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "autoFocus" | "alignItems" | "disabled" | "selected" | "divider" | "components" | "componentsProps" | "slotProps" | "slots" | "dense" | "ContainerComponent" | "ContainerProps" | "disableGutters" | "disablePadding" | "secondaryAction" | "item" | "isVisuallySelected" | "truncateLabel"> & React.RefAttributes<HTMLDivElement>>>;
33
+ export declare const ListLegendItem: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<ListLegendItemProps, "classes" | "className" | "style" | "children" | "sx" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "autoFocus" | "alignItems" | "disabled" | "selected" | "divider" | "components" | "componentsProps" | "slotProps" | "slots" | "dense" | "ContainerComponent" | "ContainerProps" | "disableGutters" | "disablePadding" | "secondaryAction" | "item" | "index" | "isVisuallySelected" | "truncateLabel"> & React.RefAttributes<HTMLDivElement>>>;
21
34
  //# sourceMappingURL=ListLegendItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListLegendItem.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegendItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAA+B,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAChF,IAA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G;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA0DD,eAAO,MAAM,cAAc,86JAAiC,CAAC"}
@@ -16,14 +16,14 @@ import React, { forwardRef, useState } from 'react';
16
16
  import { Box, ListItemText, ListItem } from '@mui/material';
17
17
  import { combineSx } from '../utils';
18
18
  import { LegendColorBadge } from './LegendColorBadge';
19
- const ListLegendItemBase = /*#__PURE__*/ forwardRef(function ListLegendItem({ item , sx , truncateLabel , onClick , isVisuallySelected , ...others }, ref) {
19
+ const ListLegendItemBase = /*#__PURE__*/ forwardRef(function ListLegendItem({ item , sx , truncateLabel , onClick , isVisuallySelected , onMouseOver , onMouseOut , index , ...others }, ref) {
20
20
  const [noWrap, setNoWrap] = useState(truncateLabel);
21
- function handleMouseOver() {
21
+ function handleTextMouseOver() {
22
22
  if (truncateLabel) {
23
23
  setNoWrap(false);
24
24
  }
25
25
  }
26
- function handleMouseOut() {
26
+ function handleTextMouseOut() {
27
27
  if (truncateLabel) {
28
28
  setNoWrap(true);
29
29
  }
@@ -44,6 +44,18 @@ const ListLegendItemBase = /*#__PURE__*/ forwardRef(function ListLegendItem({ it
44
44
  dense: true,
45
45
  key: item.id,
46
46
  onClick: handleClick,
47
+ onMouseOver: (e)=>{
48
+ return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, {
49
+ id: item.id,
50
+ index
51
+ });
52
+ },
53
+ onMouseOut: (e)=>{
54
+ return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, {
55
+ id: item.id,
56
+ index
57
+ });
58
+ },
47
59
  selected: isVisuallySelected,
48
60
  ref: ref,
49
61
  children: [
@@ -61,8 +73,8 @@ const ListLegendItemBase = /*#__PURE__*/ forwardRef(function ListLegendItem({ it
61
73
  primaryTypographyProps: {
62
74
  noWrap: noWrap
63
75
  },
64
- onMouseOver: handleMouseOver,
65
- onMouseOut: handleMouseOut
76
+ onMouseOver: handleTextMouseOver,
77
+ onMouseOut: handleTextMouseOut
66
78
  })
67
79
  ]
68
80
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/ListLegendItem.tsx"],"sourcesContent":["// Copyright 2023 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 React, { forwardRef, useState } from 'react';\nimport { Box, ListItemText, ListItem, ListItemProps } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { combineSx } from '../utils';\nimport { LegendColorBadge } from './LegendColorBadge';\n\nexport interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick'> {\n item: LegendItem;\n\n /**\n * When true, the item is rendered differently to visually communicate it is\n * selected.\n */\n isVisuallySelected?: boolean;\n\n onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => void;\n\n /**\n * When `true`, will keep labels to a single line with overflow ellipsized. The\n * full content will be shown on hover.\n *\n * When `false` or unset, will show the full label.\n */\n truncateLabel?: boolean;\n}\n\nconst ListLegendItemBase = forwardRef<HTMLDivElement, ListLegendItemProps>(function ListLegendItem(\n { item, sx, truncateLabel, onClick, isVisuallySelected, ...others },\n ref\n) {\n const [noWrap, setNoWrap] = useState(truncateLabel);\n\n function handleMouseOver() {\n if (truncateLabel) {\n setNoWrap(false);\n }\n }\n\n function handleMouseOut() {\n if (truncateLabel) {\n setNoWrap(true);\n }\n }\n\n const handleClick: React.MouseEventHandler<HTMLDivElement> = (e) => {\n onClick(e, item.id);\n item.onClick?.(e);\n };\n\n return (\n <ListItem\n {...others}\n component=\"div\"\n role=\"listitem\"\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx\n )}\n dense={true}\n key={item.id}\n onClick={handleClick}\n selected={isVisuallySelected}\n ref={ref}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText\n primary={item.label}\n primaryTypographyProps={{ noWrap: noWrap }}\n onMouseOver={handleMouseOver}\n onMouseOut={handleMouseOut}\n ></ListItemText>\n </ListItem>\n );\n});\n\nexport const ListLegendItem = React.memo(ListLegendItemBase);\n"],"names":["React","forwardRef","useState","Box","ListItemText","ListItem","combineSx","LegendColorBadge","ListLegendItemBase","ListLegendItem","item","sx","truncateLabel","onClick","isVisuallySelected","others","ref","noWrap","setNoWrap","handleMouseOver","handleMouseOut","handleClick","e","id","component","role","padding","cursor","dense","key","selected","display","alignItems","color","primary","label","primaryTypographyProps","onMouseOver","onMouseOut","memo"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACpD,SAASC,GAAG,EAAEC,YAAY,EAAEC,QAAQ,QAAuB,eAAe,CAAC;AAE3E,SAASC,SAAS,QAAQ,UAAU,CAAC;AACrC,SAASC,gBAAgB,QAAQ,oBAAoB,CAAC;AAsBtD,MAAMC,kBAAkB,iBAAGP,UAAU,CAAsC,SAASQ,cAAc,CAChG,EAAEC,IAAI,CAAA,EAAEC,EAAE,CAAA,EAAEC,aAAa,CAAA,EAAEC,OAAO,CAAA,EAAEC,kBAAkB,CAAA,EAAE,GAAGC,MAAM,EAAE,EACnEC,GAAG,EACH;IACA,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGhB,QAAQ,CAACU,aAAa,CAAC,AAAC;IAEpD,SAASO,eAAe,GAAG;QACzB,IAAIP,aAAa,EAAE;YACjBM,SAAS,C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AGT,KAAK,CAACuC,IAAI,CAAC/B,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/ListLegendItem.tsx"],"sourcesContent":["// Copyright 2023 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 React, { forwardRef, useState } from 'react';\nimport { Box, ListItemText, ListItem, ListItemProps } from '@mui/material';\nimport { combineSx } from '../utils';\nimport { LegendColorBadge } from './LegendColorBadge';\nimport { LegendItem } from './legend-model';\n\nexport type LegendItemEventOpts = {\n /**\n * Unique identifier for the legend item.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick' | 'onMouseOver' | 'onMouseOut'> {\n item: LegendItem;\n\n index: number;\n\n /**\n * When true, the item is rendered differently to visually communicate it is\n * selected.\n */\n isVisuallySelected?: boolean;\n\n onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => void;\n\n onMouseOver?: (e: React.MouseEvent, opts: LegendItemEventOpts) => void;\n onMouseOut?: (e: React.MouseEvent, opts: LegendItemEventOpts) => void;\n\n /**\n * When `true`, will keep labels to a single line with overflow ellipsized. The\n * full content will be shown on hover.\n *\n * When `false` or unset, will show the full label.\n */\n truncateLabel?: boolean;\n}\n\nconst ListLegendItemBase = forwardRef<HTMLDivElement, ListLegendItemProps>(function ListLegendItem(\n { item, sx, truncateLabel, onClick, isVisuallySelected, onMouseOver, onMouseOut, index, ...others },\n ref\n) {\n const [noWrap, setNoWrap] = useState(truncateLabel);\n\n function handleTextMouseOver() {\n if (truncateLabel) {\n setNoWrap(false);\n }\n }\n\n function handleTextMouseOut() {\n if (truncateLabel) {\n setNoWrap(true);\n }\n }\n\n const handleClick: React.MouseEventHandler<HTMLDivElement> = (e) => {\n onClick(e, item.id);\n item.onClick?.(e);\n };\n\n return (\n <ListItem\n {...others}\n component=\"div\"\n role=\"listitem\"\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx\n )}\n dense={true}\n key={item.id}\n onClick={handleClick}\n onMouseOver={(e: React.MouseEvent) => onMouseOver?.(e, { id: item.id, index })}\n onMouseOut={(e: React.MouseEvent) => onMouseOut?.(e, { id: item.id, index })}\n selected={isVisuallySelected}\n ref={ref}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText\n primary={item.label}\n primaryTypographyProps={{ noWrap: noWrap }}\n onMouseOver={handleTextMouseOver}\n onMouseOut={handleTextMouseOut}\n ></ListItemText>\n </ListItem>\n );\n});\n\nexport const ListLegendItem = React.memo(ListLegendItemBase);\n"],"names":["React","forwardRef","useState","Box","ListItemText","ListItem","combineSx","LegendColorBadge","ListLegendItemBase","ListLegendItem","item","sx","truncateLabel","onClick","isVisuallySelected","onMouseOver","onMouseOut","index","others","ref","noWrap","setNoWrap","handleTextMouseOver","handleTextMouseOut","handleClick","e","id","component","role","padding","cursor","dense","key","selected","display","alignItems","color","primary","label","primaryTypographyProps","memo"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACpD,SAASC,GAAG,EAAEC,YAAY,EAAEC,QAAQ,QAAuB,eAAe,CAAC;AAC3E,SAASC,SAAS,QAAQ,UAAU,CAAC;AACrC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OAAAA,WAAW,aAAXA,WAAW,WAA6B,GAAxCA,KAAAA,CAAwC,GAAxCA,WAAW,CAAGU,CAAC,EAAE;gBAAEC,EAAE,EAAEhB,IAAI,CAACgB,EAAE;gBAAET,KAAK;aAAE,CAAC,CAAA;SAAA;QAC9ED,UAAU,EAAE,CAACS,CAAmB;YAAKT,OAAAA,UAAU,aAAVA,UAAU,WAA6B,GAAvCA,KAAAA,CAAuC,GAAvCA,UAAU,CAAGS,CAAC,EAAE;gBAAEC,EAAE,EAAEhB,IAAI,CAACgB,EAAE;gBAAET,KAAK;aAAE,CAAC,CAAA;SAAA;QAC5EgB,QAAQ,EAAEnB,kBAAkB;QAC5BK,GAAG,EAAEA,GAAG;;0BAER,KAAChB,GAAG;gBAACQ,EAAE,EAAE;oBAAEuB,OAAO,EAAE,MAAM;oBAAEC,UAAU,EAAE,QAAQ;iBAAE;0BAChD,cAAA,KAAC5B,gBAAgB;oBAAC6B,KAAK,EAAE1B,IAAI,CAAC0B,KAAK;kBAAI;cACnC;0BACN,KAAChC,YAAY;gBACXiC,OAAO,EAAE3B,IAAI,CAAC4B,KAAK;gBACnBC,sBAAsB,EAAE;oBAAEnB,MAAM,EAAEA,MAAM;iBAAE;gBAC1CL,WAAW,EAAEO,mBAAmB;gBAChCN,UAAU,EAAEO,kBAAkB;cAChB;;MACP,CACX;AACJ,CAAC,CAAC,AAAC;AAEH,OAAO,MAAMd,cAAc,iBAAGT,KAAK,CAACwC,IAAI,CAAChC,kBAAkB,CAAC,CAAC"}
@@ -1,12 +1,15 @@
1
1
  /// <reference types="react" />
2
2
  import { TableProps } from '../Table';
3
- import { LegendItem } from '../model';
4
- export interface TableLegendProps {
3
+ import { LegendItem } from './legend-model';
4
+ export interface TableLegendProps extends Pick<TableProps<LegendItem>, 'sorting' | 'onSortingChange'> {
5
5
  items: LegendItem[];
6
6
  height: number;
7
7
  width: number;
8
8
  selectedItems: TableProps<LegendItem>['rowSelection'] | 'ALL';
9
9
  onSelectedItemsChange: TableProps<LegendItem>['onRowSelectionChange'];
10
+ onItemMouseOver?: TableProps<LegendItem>['onRowMouseOver'];
11
+ onItemMouseOut?: TableProps<LegendItem>['onRowMouseOut'];
12
+ columns?: TableProps<LegendItem>['columns'];
10
13
  }
11
- export declare function TableLegend({ items, selectedItems: initRowSelection, onSelectedItemsChange, height, width, }: TableLegendProps): JSX.Element;
14
+ export declare function TableLegend({ items, selectedItems: initRowSelection, onSelectedItemsChange, onItemMouseOver, onItemMouseOut, height, width, columns: additionalColumns, sorting, onSortingChange, }: TableLegendProps): JSX.Element;
12
15
  //# sourceMappingURL=TableLegend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/TableLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAS,UAAU,EAAqB,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;IAC9D,qBAAqB,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,sBAAsB,CAAC,CAAC;CACvE;AAsBD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,aAAa,EAAE,gBAAgB,EAC/B,qBAAqB,EACrB,MAAM,EACN,KAAK,GACN,EAAE,gBAAgB,eA2BlB"}
1
+ {"version":3,"file":"TableLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/TableLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAS,UAAU,EAAqB,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,iBAAiB,CAAC;IACnG,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;IAC9D,qBAAqB,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACtE,eAAe,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC3D,cAAc,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;CAC7C;AAuBD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,aAAa,EAAE,gBAAgB,EAC/B,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,MAAM,EACN,KAAK,EACL,OAAO,EAAE,iBAAsB,EAC/B,OAAO,EACP,eAAe,GAChB,EAAE,gBAAgB,eAoClB"}
@@ -17,6 +17,7 @@ const COLUMNS = [
17
17
  {
18
18
  accessorKey: 'label',
19
19
  header: 'Name',
20
+ enableSorting: true,
20
21
  // Starting with `title` attr instead of a tooltip because it is easier to
21
22
  // implement. We should try adding a tooltip in the future, but we'll need
22
23
  // to be very careful about performance when doing so with large tables.
@@ -32,7 +33,7 @@ const getRowId = (data)=>{
32
33
  const getCheckboxColor = (data)=>{
33
34
  return data.color;
34
35
  };
35
- export function TableLegend({ items , selectedItems: initRowSelection , onSelectedItemsChange , height , width }) {
36
+ export function TableLegend({ items , selectedItems: initRowSelection , onSelectedItemsChange , onItemMouseOver , onItemMouseOut , height , width , columns: additionalColumns = [] , sorting , onSortingChange }) {
36
37
  const rowSelection = useMemo(()=>{
37
38
  return typeof initRowSelection !== 'string' ? initRowSelection : // items for checkboxes.
38
39
  // TODO: clean this up if we switch to also using checkboxes in list legend.
@@ -44,17 +45,30 @@ export function TableLegend({ items , selectedItems: initRowSelection , onSelect
44
45
  initRowSelection,
45
46
  items
46
47
  ]);
48
+ const columns = useMemo(()=>{
49
+ return [
50
+ ...COLUMNS,
51
+ ...additionalColumns
52
+ ];
53
+ }, [
54
+ additionalColumns
55
+ ]);
47
56
  return /*#__PURE__*/ _jsx(Table, {
48
57
  height: height,
49
58
  width: width,
50
59
  rowSelection: rowSelection,
51
60
  onRowSelectionChange: onSelectedItemsChange,
61
+ onRowMouseOver: onItemMouseOver,
62
+ onRowMouseOut: onItemMouseOut,
63
+ sorting: sorting,
64
+ onSortingChange: onSortingChange,
52
65
  data: items,
53
- columns: COLUMNS,
66
+ columns: columns,
54
67
  density: "compact",
55
68
  getRowId: getRowId,
56
69
  getCheckboxColor: getCheckboxColor,
57
- checkboxSelection: true
70
+ checkboxSelection: true,
71
+ rowSelectionVariant: "legend"
58
72
  });
59
73
  }
60
74