@perses-dev/components 0.39.0 → 0.40.1

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 (328) hide show
  1. package/dist/BarChart/BarChart.d.ts +2 -2
  2. package/dist/BarChart/BarChart.d.ts.map +1 -1
  3. package/dist/BarChart/BarChart.js +8 -8
  4. package/dist/BarChart/BarChart.js.map +1 -1
  5. package/dist/BarChart/index.js.map +1 -1
  6. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  7. package/dist/ColorPicker/index.js.map +1 -1
  8. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  9. package/dist/ContentWithLegend/index.js.map +1 -1
  10. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
  11. package/dist/ContentWithLegend/model/content-with-legend-model.js +19 -19
  12. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  13. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -1
  14. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js +6 -22
  15. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -1
  16. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  17. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  18. package/dist/DateTimeRangePicker/index.js.map +1 -1
  19. package/dist/DateTimeRangePicker/utils.js.map +1 -1
  20. package/dist/Dialog/Dialog.js.map +1 -1
  21. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  22. package/dist/Dialog/index.js.map +1 -1
  23. package/dist/Drawer/Drawer.js.map +1 -1
  24. package/dist/Drawer/index.js.map +1 -1
  25. package/dist/EChart/EChart.js +2 -2
  26. package/dist/EChart/EChart.js.map +1 -1
  27. package/dist/EChart/index.js.map +1 -1
  28. package/dist/ErrorAlert.js.map +1 -1
  29. package/dist/ErrorBoundary.js.map +1 -1
  30. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
  31. package/dist/FontSizeSelector/index.js.map +1 -1
  32. package/dist/FormatControls/FormatControls.d.ts +9 -0
  33. package/dist/FormatControls/FormatControls.d.ts.map +1 -0
  34. package/dist/{UnitSelector/UnitSelector.js → FormatControls/FormatControls.js} +26 -26
  35. package/dist/FormatControls/FormatControls.js.map +1 -0
  36. package/dist/FormatControls/index.d.ts +2 -0
  37. package/dist/FormatControls/index.d.ts.map +1 -0
  38. package/dist/{UnitSelector → FormatControls}/index.js +1 -1
  39. package/dist/FormatControls/index.js.map +1 -0
  40. package/dist/GaugeChart/GaugeChart.d.ts +3 -3
  41. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  42. package/dist/GaugeChart/GaugeChart.js +11 -11
  43. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  44. package/dist/GaugeChart/index.js.map +1 -1
  45. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  46. package/dist/InfoTooltip/index.js.map +1 -1
  47. package/dist/JSONEditor.js.map +1 -1
  48. package/dist/Legend/CompactLegend.js.map +1 -1
  49. package/dist/Legend/Legend.js +3 -3
  50. package/dist/Legend/Legend.js.map +1 -1
  51. package/dist/Legend/LegendColorBadge.js.map +1 -1
  52. package/dist/Legend/ListLegend.js.map +1 -1
  53. package/dist/Legend/ListLegendItem.js +2 -2
  54. package/dist/Legend/ListLegendItem.js.map +1 -1
  55. package/dist/Legend/TableLegend.js.map +1 -1
  56. package/dist/Legend/index.js.map +1 -1
  57. package/dist/Legend/legend-model.js.map +1 -1
  58. package/dist/LineChart/LineChart.d.ts +2 -2
  59. package/dist/LineChart/LineChart.d.ts.map +1 -1
  60. package/dist/LineChart/LineChart.js +12 -12
  61. package/dist/LineChart/LineChart.js.map +1 -1
  62. package/dist/LineChart/index.js.map +1 -1
  63. package/dist/ModeSelector/ModeSelector.js.map +1 -1
  64. package/dist/ModeSelector/index.js.map +1 -1
  65. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  66. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  67. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  68. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  69. package/dist/OptionsEditorLayout/index.js.map +1 -1
  70. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  71. package/dist/RefreshIntervalPicker/index.js.map +1 -1
  72. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +2 -2
  73. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  74. package/dist/SettingsAutocomplete/index.js.map +1 -1
  75. package/dist/SortSelector/SortSelector.js.map +1 -1
  76. package/dist/SortSelector/index.js.map +1 -1
  77. package/dist/StatChart/StatChart.d.ts +2 -2
  78. package/dist/StatChart/StatChart.d.ts.map +1 -1
  79. package/dist/StatChart/StatChart.js +7 -7
  80. package/dist/StatChart/StatChart.js.map +1 -1
  81. package/dist/StatChart/calculateFontSize.js +4 -4
  82. package/dist/StatChart/calculateFontSize.js.map +1 -1
  83. package/dist/StatChart/index.js.map +1 -1
  84. package/dist/Table/InnerTable.js.map +1 -1
  85. package/dist/Table/Table.js.map +1 -1
  86. package/dist/Table/TableBody.js.map +1 -1
  87. package/dist/Table/TableCell.js +2 -2
  88. package/dist/Table/TableCell.js.map +1 -1
  89. package/dist/Table/TableCheckbox.js.map +1 -1
  90. package/dist/Table/TableHead.js.map +1 -1
  91. package/dist/Table/TableHeaderCell.js.map +1 -1
  92. package/dist/Table/TableRow.js.map +1 -1
  93. package/dist/Table/VirtualizedTable.js +6 -6
  94. package/dist/Table/VirtualizedTable.js.map +1 -1
  95. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  96. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  97. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +20 -20
  98. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  99. package/dist/Table/index.js.map +1 -1
  100. package/dist/Table/model/table-model.js +9 -9
  101. package/dist/Table/model/table-model.js.map +1 -1
  102. package/dist/ThresholdsEditor/ThresholdColorPicker.js +1 -1
  103. package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -1
  104. package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
  105. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  106. package/dist/ThresholdsEditor/ThresholdsEditor.js +17 -17
  107. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  108. package/dist/ThresholdsEditor/index.js.map +1 -1
  109. package/dist/TimeChart/TimeChart.d.ts +2 -2
  110. package/dist/TimeChart/TimeChart.d.ts.map +1 -1
  111. package/dist/TimeChart/TimeChart.js +12 -12
  112. package/dist/TimeChart/TimeChart.js.map +1 -1
  113. package/dist/TimeChart/index.js.map +1 -1
  114. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +2 -2
  115. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  116. package/dist/TimeSeriesTooltip/LineChartTooltip.js +7 -7
  117. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  118. package/dist/TimeSeriesTooltip/SeriesInfo.js +2 -2
  119. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  120. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  121. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  122. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +2 -2
  123. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  124. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +4 -4
  125. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  126. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  127. package/dist/TimeSeriesTooltip/TooltipHeader.js +6 -6
  128. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  129. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  130. package/dist/TimeSeriesTooltip/nearby-series.d.ts +7 -7
  131. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  132. package/dist/TimeSeriesTooltip/nearby-series.js +29 -29
  133. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  134. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  135. package/dist/TimeSeriesTooltip/utils.js +3 -3
  136. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  137. package/dist/YAxisLabel.js.map +1 -1
  138. package/dist/cjs/BarChart/BarChart.js +17 -15
  139. package/dist/cjs/BarChart/index.js +10 -8
  140. package/dist/cjs/ColorPicker/ColorPicker.js +15 -13
  141. package/dist/cjs/ColorPicker/index.js +10 -8
  142. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +12 -10
  143. package/dist/cjs/ContentWithLegend/index.js +10 -8
  144. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +27 -23
  145. package/dist/cjs/DateTimeRangePicker/AbsoluteTimePicker.js +29 -43
  146. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +12 -10
  147. package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +13 -11
  148. package/dist/cjs/DateTimeRangePicker/index.js +12 -10
  149. package/dist/cjs/DateTimeRangePicker/utils.js +9 -5
  150. package/dist/cjs/Dialog/Dialog.js +15 -13
  151. package/dist/cjs/Dialog/DiscardChangesConfirmationDialog.js +11 -9
  152. package/dist/cjs/Dialog/index.js +11 -9
  153. package/dist/cjs/Drawer/Drawer.js +5 -3
  154. package/dist/cjs/Drawer/index.js +10 -8
  155. package/dist/cjs/EChart/EChart.js +12 -10
  156. package/dist/cjs/EChart/index.js +10 -8
  157. package/dist/cjs/ErrorAlert.js +5 -3
  158. package/dist/cjs/ErrorBoundary.js +4 -2
  159. package/dist/cjs/FontSizeSelector/FontSizeSelector.js +8 -6
  160. package/dist/cjs/FontSizeSelector/index.js +10 -8
  161. package/dist/cjs/{UnitSelector/UnitSelector.js → FormatControls/FormatControls.js} +38 -36
  162. package/dist/cjs/{UnitSelector → FormatControls}/index.js +10 -8
  163. package/dist/cjs/GaugeChart/GaugeChart.js +22 -18
  164. package/dist/cjs/GaugeChart/index.js +10 -8
  165. package/dist/cjs/InfoTooltip/InfoTooltip.js +13 -11
  166. package/dist/cjs/InfoTooltip/index.js +10 -8
  167. package/dist/cjs/JSONEditor.js +10 -8
  168. package/dist/cjs/Legend/CompactLegend.js +9 -7
  169. package/dist/cjs/Legend/Legend.js +15 -13
  170. package/dist/cjs/Legend/LegendColorBadge.js +7 -5
  171. package/dist/cjs/Legend/ListLegend.js +10 -8
  172. package/dist/cjs/Legend/ListLegendItem.js +12 -10
  173. package/dist/cjs/Legend/TableLegend.js +7 -5
  174. package/dist/cjs/Legend/index.js +11 -9
  175. package/dist/cjs/Legend/legend-model.js +3 -1
  176. package/dist/cjs/LineChart/LineChart.js +24 -22
  177. package/dist/cjs/LineChart/index.js +10 -8
  178. package/dist/cjs/ModeSelector/ModeSelector.js +8 -6
  179. package/dist/cjs/ModeSelector/index.js +10 -8
  180. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +6 -4
  181. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +16 -14
  182. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +5 -3
  183. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +11 -9
  184. package/dist/cjs/OptionsEditorLayout/index.js +13 -11
  185. package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +8 -6
  186. package/dist/cjs/RefreshIntervalPicker/index.js +10 -8
  187. package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +12 -10
  188. package/dist/cjs/SettingsAutocomplete/index.js +10 -8
  189. package/dist/cjs/SortSelector/SortSelector.js +8 -6
  190. package/dist/cjs/SortSelector/index.js +10 -8
  191. package/dist/cjs/StatChart/StatChart.js +20 -18
  192. package/dist/cjs/StatChart/calculateFontSize.js +9 -7
  193. package/dist/cjs/StatChart/index.js +10 -8
  194. package/dist/cjs/Table/InnerTable.js +5 -3
  195. package/dist/cjs/Table/Table.js +15 -13
  196. package/dist/cjs/Table/TableBody.js +5 -3
  197. package/dist/cjs/Table/TableCell.js +10 -8
  198. package/dist/cjs/Table/TableCheckbox.js +5 -3
  199. package/dist/cjs/Table/TableHead.js +5 -3
  200. package/dist/cjs/Table/TableHeaderCell.js +8 -6
  201. package/dist/cjs/Table/TableRow.js +5 -3
  202. package/dist/cjs/Table/VirtualizedTable.js +32 -30
  203. package/dist/cjs/Table/VirtualizedTableContainer.js +5 -3
  204. package/dist/cjs/Table/hooks/useTableKeyboardNav.js +3 -1
  205. package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +23 -21
  206. package/dist/cjs/Table/index.js +14 -10
  207. package/dist/cjs/Table/model/table-model.js +15 -11
  208. package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +15 -13
  209. package/dist/cjs/ThresholdsEditor/ThresholdInput.js +14 -12
  210. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +44 -42
  211. package/dist/cjs/ThresholdsEditor/index.js +10 -8
  212. package/dist/cjs/TimeChart/TimeChart.js +31 -29
  213. package/dist/cjs/TimeChart/index.js +10 -8
  214. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +28 -26
  215. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +17 -15
  216. package/dist/cjs/TimeSeriesTooltip/SeriesLabelsStack.js +15 -13
  217. package/dist/cjs/TimeSeriesTooltip/SeriesMarker.js +5 -3
  218. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +22 -20
  219. package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +7 -5
  220. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +34 -32
  221. package/dist/cjs/TimeSeriesTooltip/index.js +19 -17
  222. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +56 -38
  223. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +51 -17
  224. package/dist/cjs/TimeSeriesTooltip/utils.js +17 -13
  225. package/dist/cjs/YAxisLabel.js +6 -4
  226. package/dist/cjs/context/ChartsProvider.js +16 -8
  227. package/dist/cjs/context/SnackbarProvider.js +6 -2
  228. package/dist/cjs/context/TimeZoneProvider.js +13 -7
  229. package/dist/cjs/context/index.js +12 -10
  230. package/dist/cjs/index.js +41 -39
  231. package/dist/cjs/model/graph.js +9 -3
  232. package/dist/cjs/model/index.js +12 -10
  233. package/dist/cjs/test/index.js +10 -8
  234. package/dist/cjs/test/render.js +7 -5
  235. package/dist/cjs/test-utils/index.js +10 -8
  236. package/dist/cjs/test-utils/theme.js +6 -2
  237. package/dist/cjs/theme/component-overrides/alert.js +3 -1
  238. package/dist/cjs/theme/component-overrides/paper.js +3 -1
  239. package/dist/cjs/theme/index.js +10 -8
  240. package/dist/cjs/theme/palette/background.js +6 -2
  241. package/dist/cjs/theme/palette/colors/blue.js +3 -1
  242. package/dist/cjs/theme/palette/colors/common.js +6 -2
  243. package/dist/cjs/theme/palette/colors/green.js +3 -1
  244. package/dist/cjs/theme/palette/colors/grey.js +3 -1
  245. package/dist/cjs/theme/palette/colors/index.js +17 -15
  246. package/dist/cjs/theme/palette/colors/orange.js +3 -1
  247. package/dist/cjs/theme/palette/colors/purple.js +3 -1
  248. package/dist/cjs/theme/palette/colors/red.js +3 -1
  249. package/dist/cjs/theme/palette/error.js +3 -1
  250. package/dist/cjs/theme/palette/grey.js +3 -1
  251. package/dist/cjs/theme/palette/index.js +10 -8
  252. package/dist/cjs/theme/palette/palette-options.js +3 -1
  253. package/dist/cjs/theme/palette/primary.js +3 -1
  254. package/dist/cjs/theme/palette/secondary.js +3 -1
  255. package/dist/cjs/theme/palette/success.js +3 -1
  256. package/dist/cjs/theme/palette/text.js +3 -1
  257. package/dist/cjs/theme/palette/warning.js +3 -1
  258. package/dist/cjs/theme/theme.js +5 -3
  259. package/dist/cjs/theme/typography.js +3 -1
  260. package/dist/cjs/utils/axis.js +8 -4
  261. package/dist/cjs/utils/chart-actions.js +26 -10
  262. package/dist/cjs/utils/combine-sx.js +3 -1
  263. package/dist/cjs/utils/component-ids.js +3 -1
  264. package/dist/cjs/utils/format.js +16 -8
  265. package/dist/cjs/utils/index.js +15 -13
  266. package/dist/cjs/utils/mathjs.js +3 -1
  267. package/dist/cjs/utils/theme-gen.js +12 -10
  268. package/dist/context/ChartsProvider.js.map +1 -1
  269. package/dist/context/SnackbarProvider.js.map +1 -1
  270. package/dist/context/TimeZoneProvider.js.map +1 -1
  271. package/dist/context/index.js.map +1 -1
  272. package/dist/index.d.ts +1 -1
  273. package/dist/index.d.ts.map +1 -1
  274. package/dist/index.js +1 -1
  275. package/dist/index.js.map +1 -1
  276. package/dist/model/graph.js.map +1 -1
  277. package/dist/model/index.js.map +1 -1
  278. package/dist/test/index.js.map +1 -1
  279. package/dist/test/render.js.map +1 -1
  280. package/dist/test/setup-tests.js.map +1 -1
  281. package/dist/test-utils/index.js.map +1 -1
  282. package/dist/test-utils/theme.js.map +1 -1
  283. package/dist/theme/component-overrides/alert.js.map +1 -1
  284. package/dist/theme/component-overrides/paper.js.map +1 -1
  285. package/dist/theme/index.d.ts +1 -0
  286. package/dist/theme/index.d.ts.map +1 -1
  287. package/dist/theme/index.js.map +1 -1
  288. package/dist/theme/palette/background.d.ts.map +1 -1
  289. package/dist/theme/palette/background.js +3 -1
  290. package/dist/theme/palette/background.js.map +1 -1
  291. package/dist/theme/palette/colors/blue.js.map +1 -1
  292. package/dist/theme/palette/colors/common.js.map +1 -1
  293. package/dist/theme/palette/colors/green.js.map +1 -1
  294. package/dist/theme/palette/colors/grey.js.map +1 -1
  295. package/dist/theme/palette/colors/index.js.map +1 -1
  296. package/dist/theme/palette/colors/orange.js.map +1 -1
  297. package/dist/theme/palette/colors/purple.js.map +1 -1
  298. package/dist/theme/palette/colors/red.js.map +1 -1
  299. package/dist/theme/palette/error.js.map +1 -1
  300. package/dist/theme/palette/grey.js.map +1 -1
  301. package/dist/theme/palette/index.js.map +1 -1
  302. package/dist/theme/palette/palette-options.js.map +1 -1
  303. package/dist/theme/palette/primary.js.map +1 -1
  304. package/dist/theme/palette/secondary.js.map +1 -1
  305. package/dist/theme/palette/success.js.map +1 -1
  306. package/dist/theme/palette/text.js.map +1 -1
  307. package/dist/theme/palette/warning.js.map +1 -1
  308. package/dist/theme/theme.js.map +1 -1
  309. package/dist/theme/typography.js.map +1 -1
  310. package/dist/utils/axis.d.ts +2 -2
  311. package/dist/utils/axis.d.ts.map +1 -1
  312. package/dist/utils/axis.js.map +1 -1
  313. package/dist/utils/chart-actions.js +2 -2
  314. package/dist/utils/chart-actions.js.map +1 -1
  315. package/dist/utils/combine-sx.js.map +1 -1
  316. package/dist/utils/component-ids.js.map +1 -1
  317. package/dist/utils/format.js.map +1 -1
  318. package/dist/utils/index.js.map +1 -1
  319. package/dist/utils/mathjs.js.map +1 -1
  320. package/dist/utils/theme-gen.js +7 -7
  321. package/dist/utils/theme-gen.js.map +1 -1
  322. package/package.json +7 -6
  323. package/dist/UnitSelector/UnitSelector.d.ts +0 -9
  324. package/dist/UnitSelector/UnitSelector.d.ts.map +0 -1
  325. package/dist/UnitSelector/UnitSelector.js.map +0 -1
  326. package/dist/UnitSelector/index.d.ts +0 -2
  327. package/dist/UnitSelector/index.d.ts.map +0 -1
  328. package/dist/UnitSelector/index.js.map +0 -1
@@ -36,17 +36,17 @@ function calculateTableCellHeight(lineHeight, paddingY) {
36
36
  };
37
37
  }
38
38
  // standard density
39
- const paddingY1 = theme.spacing(1);
40
- const basePaddingX1 = theme.spacing(1.25);
41
- const edgePaddingX1 = theme.spacing(2);
42
- const paddingLeft1 = isFirstColumn ? edgePaddingX1 : basePaddingX1;
43
- const paddingRight1 = isLastColumn ? edgePaddingX1 : basePaddingX1;
44
- const lineHeight1 = theme.typography.body1.lineHeight;
39
+ const paddingY = theme.spacing(1);
40
+ const basePaddingX = theme.spacing(1.25);
41
+ const edgePaddingX = theme.spacing(2);
42
+ const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;
43
+ const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;
44
+ const lineHeight = theme.typography.body1.lineHeight;
45
45
  return {
46
- padding: `${paddingY1} ${paddingRight1} ${paddingY1} ${paddingLeft1}`,
47
- height: calculateTableCellHeight(lineHeight1, paddingY1),
46
+ padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,
47
+ height: calculateTableCellHeight(lineHeight, paddingY),
48
48
  fontSize: theme.typography.body1.fontSize,
49
- lineHeight: lineHeight1
49
+ lineHeight: lineHeight
50
50
  };
51
51
  }
52
52
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Table/model/table-model.ts"],"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 { Theme } from '@mui/material';\nimport {\n AccessorKeyColumnDef,\n CellContext,\n ColumnDef,\n CoreOptions,\n RowData,\n RowSelectionState,\n SortingState,\n} from '@tanstack/react-table';\nimport { CSSProperties } from 'react';\n\nexport type TableDensity = 'compact' | 'standard';\nexport type SortDirection = 'asc' | 'desc' | undefined;\n\nexport type TableRowEventOpts = {\n /**\n * Unique identifier for the row.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface TableProps<TableData> {\n /**\n * Height of the table.\n */\n height: number;\n\n /**\n * Width of the table.\n */\n width: number;\n\n /**\n * Array of data to render in the table. Each entry in the array will be\n * rendered as a row in the table.\n */\n data: TableData[];\n\n /**\n * Array of column configuration for the table. Each entry in the array will\n * be rendered as a column header and impact the rendering of cells within\n * table rows.\n */\n columns: Array<TableColumnConfig<TableData>>;\n\n /**\n * The density of the table layout. This impacts the size and space taken up\n * by content in the table (e.g. font size, padding).\n */\n density?: TableDensity;\n\n /**\n * When `true`, the first column of the table will include checkboxes.\n */\n checkboxSelection?: boolean;\n\n /**\n * Determines the behavior of row selection.\n *\n * - `standard`: clicking a checkbox will toggle that rows's selected/unselected\n * state and will not impact other rows.\n * - `legend`: clicking a checkbox will \"focus\" that row by selecting it and\n * unselecting other rows. Clicking a checkbox with a modifier key pressed,\n * will change this behavior to behave like `standard`.\n *\n * @default 'standard'\n */\n rowSelectionVariant?: 'standard' | 'legend';\n\n /**\n * State of selected rows in the table when `checkboxSelection` is enabled.\n *\n * Selected row state is a controlled value that should be managed using a\n * combination of this prop and `onRowSelectionChange`.\n */\n rowSelection?: RowSelectionState;\n\n /**\n * Callback fired when the mouse is moved over a table row.\n */\n onRowMouseOver?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * Callback fired when the mouse is moved out of a table row.\n */\n onRowMouseOut?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * State of the column sorting in the table.\n *\n * The column sorting is a controlled value that should be managed using a\n * combination fo this prop and `onSortingChange`.\n */\n sorting?: SortingState;\n\n /**\n * Callback fired when the selected rows in the table changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n\n /**\n * Callback fired when the table sorting changes.\n */\n onSortingChange?: (sorting: SortingState) => void;\n\n /**\n * Function used to determine the unique identifier used for each row. This\n * value is used to key `rowSelection`. If this value is not set, the index\n * is used as the unique identifier.\n */\n getRowId?: CoreOptions<TableData>['getRowId'];\n\n /**\n * Function used to determine the color of the checkbox when `checkboxSelection`\n * is enabled. If not set, a default color is used.\n */\n getCheckboxColor?: (rowData: TableData) => string;\n}\n\nfunction calculateTableCellHeight(lineHeight: CSSProperties['lineHeight'], paddingY: string): number {\n // Doing a bunch of math to enforce height to avoid weirdness with mismatched\n // heights based on customization of cell contents.\n const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight ?? 0;\n const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;\n\n return lineHeightNum + verticalPaddingNum * 2;\n}\n\ntype TableCellLayout = NonNullable<Pick<React.CSSProperties, 'padding' | 'fontSize' | 'lineHeight'>> & {\n height: number;\n};\n\ntype GetTableCellLayoutOpts = {\n isLastColumn?: boolean;\n isFirstColumn?: boolean;\n};\n\n/**\n * Returns the properties to lay out the content of table cells based on the\n * theme and density.\n */\nexport function getTableCellLayout(\n theme: Theme,\n density: TableDensity,\n { isLastColumn, isFirstColumn }: GetTableCellLayoutOpts = {}\n): TableCellLayout {\n if (density === 'compact') {\n const paddingY = theme.spacing(0.5);\n\n const basePaddingX = theme.spacing(0.5);\n const edgePaddingX = theme.spacing(1);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n\n const lineHeight = theme.typography.body2.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body2.fontSize,\n lineHeight: lineHeight,\n };\n }\n\n // standard density\n const paddingY = theme.spacing(1);\n const basePaddingX = theme.spacing(1.25);\n const edgePaddingX = theme.spacing(2);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n const lineHeight = theme.typography.body1.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body1.fontSize,\n lineHeight: lineHeight,\n };\n}\n\nexport type TableCellAlignment = 'left' | 'right' | 'center';\n\n// Overrides of meta value, so it can have a meaningful type in our code instead\n// of `any`. Putting this in the model instead of a separate .d.ts file because\n// I couldn't get it to work properly that way and punted on figuring it out\n// after trying several things.\ndeclare module '@tanstack/table-core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnConfig<TData>['align'];\n headerDescription?: TableColumnConfig<TData>['headerDescription'];\n cellDescription?: TableColumnConfig<TData>['cellDescription'];\n }\n}\n\n// Only exposing a very simplified version of the very extensive column definitions\n// possible with tanstack table to make it easier for us to control rendering\n// and functionality.\nexport interface TableColumnConfig<TableData>\n // Any needed to work around some typing issues with tanstack query.\n // https://github.com/TanStack/table/issues/4241\n // TODO: revisit issue thread and see if there are any workarounds we can\n // use.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell' | 'sortingFn'> {\n /**\n * Text to display in the header for the column.\n */\n header: string;\n\n /**\n * Alignment of the content in the cell.\n */\n align?: TableCellAlignment;\n\n /**\n * Text to display when hovering over a cell. This can be useful for\n * providing additional information about the column when the content is\n * ellipsized to fit in the space.\n *\n * If set to `true`, it will use the value generated by the `cell` prop if it\n * can be treated as a string.\n */\n // `any` needed for same reason as no-explicit-any higher up in this type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n cellDescription?: ((props: CellContext<TableData, any>) => string) | boolean | undefined;\n\n /**\n * When `true`, the column will be sortable.\n * @default false\n */\n enableSorting?: boolean;\n\n /**\n * Text to display when hovering over the header text. This can be useful for\n * providing additional information about the column when you want to keep the\n * header text relatively short to manage the column width.\n */\n headerDescription?: string;\n\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. Adding a custom setting to manage this ourselves.\n /**\n * Width of the column when rendered in a table. It should be a number in pixels\n * or \"auto\" to allow the table to automatically adjust the width to fill\n * space.\n * @default 'auto'\n */\n width?: number | 'auto';\n}\n\n/**\n * Takes in a perses table column and transforms it into a tanstack column.\n */\nexport function persesColumnsToTanstackColumns<TableData>(columns: Array<TableColumnConfig<TableData>>) {\n const tableCols: Array<ColumnDef<TableData>> = columns.map(\n ({ width, align, headerDescription, cellDescription, enableSorting, ...otherProps }) => {\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. We translate our custom \"auto\" setting to 0 size\n // for these columns, so it is easy to fall back to auto when rendering.\n // Taking from a recommendation in this github discussion:\n // https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326\n const sizeProps =\n width === 'auto' || width === undefined\n ? {\n // All zero values are used as shorthand for \"auto\" when rendering\n // because it makes it easy to fall back. (e.g. `row.size || \"auto\"`)\n size: 0,\n minSize: 0,\n maxSize: 0,\n }\n : {\n size: width,\n };\n\n const result = {\n ...otherProps,\n ...sizeProps,\n\n // Default sorting to false, so it is very explicitly set per column.\n enableSorting: !!enableSorting,\n\n // Open-ended store for extra metadata in TanStack Table, so you can bake\n // in your own features.\n meta: {\n align,\n headerDescription,\n cellDescription,\n },\n };\n\n return result;\n }\n );\n\n return tableCols;\n}\n"],"names":["calculateTableCellHeight","lineHeight","paddingY","lineHeightNum","parseInt","verticalPaddingNum","getTableCellLayout","theme","density","isLastColumn","isFirstColumn","spacing","basePaddingX","edgePaddingX","paddingLeft","paddingRight","typography","body2","padding","height","fontSize","body1","persesColumnsToTanstackColumns","columns","tableCols","map","width","align","headerDescription","cellDescription","enableSorting","otherProps","sizeProps","undefined","size","minSize","maxSize","result","meta"],"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;AA+HjC,SAASA,wBAAwB,CAACC,UAAuC,EAAEC,QAAgB,EAAU;IACnG,6EAA6E;IAC7E,mDAAmD;IACnD,MAAMC,aAAa,GAAG,OAAOF,UAAU,KAAK,QAAQ,GAAGG,QAAQ,CAACH,UAAU,EAAE,EAAE,CAAC,GAAGA,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,CAAC,AAAC;IAClG,MAA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EF,aAAa,EAAE,CAAC,CAACA,aAAa;YAE9B,yEAAyE;YACzE,wBAAwB;YACxBQ,IAAI,EAAE;gBACJX,KAAK;gBACLC,iBAAiB;gBACjBC,eAAe;aAChB;SACF,AAAC;QAEF,OAAOQ,MAAM,CAAC;IAChB,CAAC,CACF,AAAC;IAEF,OAAOb,SAAS,CAAC;AACnB,CAAC"}
1
+ {"version":3,"sources":["../../../src/Table/model/table-model.ts"],"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 { Theme } from '@mui/material';\nimport {\n AccessorKeyColumnDef,\n CellContext,\n ColumnDef,\n CoreOptions,\n RowData,\n RowSelectionState,\n SortingState,\n} from '@tanstack/react-table';\nimport { CSSProperties } from 'react';\n\nexport type TableDensity = 'compact' | 'standard';\nexport type SortDirection = 'asc' | 'desc' | undefined;\n\nexport type TableRowEventOpts = {\n /**\n * Unique identifier for the row.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface TableProps<TableData> {\n /**\n * Height of the table.\n */\n height: number;\n\n /**\n * Width of the table.\n */\n width: number;\n\n /**\n * Array of data to render in the table. Each entry in the array will be\n * rendered as a row in the table.\n */\n data: TableData[];\n\n /**\n * Array of column configuration for the table. Each entry in the array will\n * be rendered as a column header and impact the rendering of cells within\n * table rows.\n */\n columns: Array<TableColumnConfig<TableData>>;\n\n /**\n * The density of the table layout. This impacts the size and space taken up\n * by content in the table (e.g. font size, padding).\n */\n density?: TableDensity;\n\n /**\n * When `true`, the first column of the table will include checkboxes.\n */\n checkboxSelection?: boolean;\n\n /**\n * Determines the behavior of row selection.\n *\n * - `standard`: clicking a checkbox will toggle that rows's selected/unselected\n * state and will not impact other rows.\n * - `legend`: clicking a checkbox will \"focus\" that row by selecting it and\n * unselecting other rows. Clicking a checkbox with a modifier key pressed,\n * will change this behavior to behave like `standard`.\n *\n * @default 'standard'\n */\n rowSelectionVariant?: 'standard' | 'legend';\n\n /**\n * State of selected rows in the table when `checkboxSelection` is enabled.\n *\n * Selected row state is a controlled value that should be managed using a\n * combination of this prop and `onRowSelectionChange`.\n */\n rowSelection?: RowSelectionState;\n\n /**\n * Callback fired when the mouse is moved over a table row.\n */\n onRowMouseOver?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * Callback fired when the mouse is moved out of a table row.\n */\n onRowMouseOut?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * State of the column sorting in the table.\n *\n * The column sorting is a controlled value that should be managed using a\n * combination fo this prop and `onSortingChange`.\n */\n sorting?: SortingState;\n\n /**\n * Callback fired when the selected rows in the table changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n\n /**\n * Callback fired when the table sorting changes.\n */\n onSortingChange?: (sorting: SortingState) => void;\n\n /**\n * Function used to determine the unique identifier used for each row. This\n * value is used to key `rowSelection`. If this value is not set, the index\n * is used as the unique identifier.\n */\n getRowId?: CoreOptions<TableData>['getRowId'];\n\n /**\n * Function used to determine the color of the checkbox when `checkboxSelection`\n * is enabled. If not set, a default color is used.\n */\n getCheckboxColor?: (rowData: TableData) => string;\n}\n\nfunction calculateTableCellHeight(lineHeight: CSSProperties['lineHeight'], paddingY: string): number {\n // Doing a bunch of math to enforce height to avoid weirdness with mismatched\n // heights based on customization of cell contents.\n const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight ?? 0;\n const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;\n\n return lineHeightNum + verticalPaddingNum * 2;\n}\n\ntype TableCellLayout = NonNullable<Pick<React.CSSProperties, 'padding' | 'fontSize' | 'lineHeight'>> & {\n height: number;\n};\n\ntype GetTableCellLayoutOpts = {\n isLastColumn?: boolean;\n isFirstColumn?: boolean;\n};\n\n/**\n * Returns the properties to lay out the content of table cells based on the\n * theme and density.\n */\nexport function getTableCellLayout(\n theme: Theme,\n density: TableDensity,\n { isLastColumn, isFirstColumn }: GetTableCellLayoutOpts = {}\n): TableCellLayout {\n if (density === 'compact') {\n const paddingY = theme.spacing(0.5);\n\n const basePaddingX = theme.spacing(0.5);\n const edgePaddingX = theme.spacing(1);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n\n const lineHeight = theme.typography.body2.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body2.fontSize,\n lineHeight: lineHeight,\n };\n }\n\n // standard density\n const paddingY = theme.spacing(1);\n const basePaddingX = theme.spacing(1.25);\n const edgePaddingX = theme.spacing(2);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n const lineHeight = theme.typography.body1.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body1.fontSize,\n lineHeight: lineHeight,\n };\n}\n\nexport type TableCellAlignment = 'left' | 'right' | 'center';\n\n// Overrides of meta value, so it can have a meaningful type in our code instead\n// of `any`. Putting this in the model instead of a separate .d.ts file because\n// I couldn't get it to work properly that way and punted on figuring it out\n// after trying several things.\ndeclare module '@tanstack/table-core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnConfig<TData>['align'];\n headerDescription?: TableColumnConfig<TData>['headerDescription'];\n cellDescription?: TableColumnConfig<TData>['cellDescription'];\n }\n}\n\n// Only exposing a very simplified version of the very extensive column definitions\n// possible with tanstack table to make it easier for us to control rendering\n// and functionality.\nexport interface TableColumnConfig<TableData>\n // Any needed to work around some typing issues with tanstack query.\n // https://github.com/TanStack/table/issues/4241\n // TODO: revisit issue thread and see if there are any workarounds we can\n // use.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell' | 'sortingFn'> {\n /**\n * Text to display in the header for the column.\n */\n header: string;\n\n /**\n * Alignment of the content in the cell.\n */\n align?: TableCellAlignment;\n\n /**\n * Text to display when hovering over a cell. This can be useful for\n * providing additional information about the column when the content is\n * ellipsized to fit in the space.\n *\n * If set to `true`, it will use the value generated by the `cell` prop if it\n * can be treated as a string.\n */\n // `any` needed for same reason as no-explicit-any higher up in this type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n cellDescription?: ((props: CellContext<TableData, any>) => string) | boolean | undefined;\n\n /**\n * When `true`, the column will be sortable.\n * @default false\n */\n enableSorting?: boolean;\n\n /**\n * Text to display when hovering over the header text. This can be useful for\n * providing additional information about the column when you want to keep the\n * header text relatively short to manage the column width.\n */\n headerDescription?: string;\n\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. Adding a custom setting to manage this ourselves.\n /**\n * Width of the column when rendered in a table. It should be a number in pixels\n * or \"auto\" to allow the table to automatically adjust the width to fill\n * space.\n * @default 'auto'\n */\n width?: number | 'auto';\n}\n\n/**\n * Takes in a perses table column and transforms it into a tanstack column.\n */\nexport function persesColumnsToTanstackColumns<TableData>(columns: Array<TableColumnConfig<TableData>>) {\n const tableCols: Array<ColumnDef<TableData>> = columns.map(\n ({ width, align, headerDescription, cellDescription, enableSorting, ...otherProps }) => {\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. We translate our custom \"auto\" setting to 0 size\n // for these columns, so it is easy to fall back to auto when rendering.\n // Taking from a recommendation in this github discussion:\n // https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326\n const sizeProps =\n width === 'auto' || width === undefined\n ? {\n // All zero values are used as shorthand for \"auto\" when rendering\n // because it makes it easy to fall back. (e.g. `row.size || \"auto\"`)\n size: 0,\n minSize: 0,\n maxSize: 0,\n }\n : {\n size: width,\n };\n\n const result = {\n ...otherProps,\n ...sizeProps,\n\n // Default sorting to false, so it is very explicitly set per column.\n enableSorting: !!enableSorting,\n\n // Open-ended store for extra metadata in TanStack Table, so you can bake\n // in your own features.\n meta: {\n align,\n headerDescription,\n cellDescription,\n },\n };\n\n return result;\n }\n );\n\n return tableCols;\n}\n"],"names":["calculateTableCellHeight","lineHeight","paddingY","lineHeightNum","parseInt","verticalPaddingNum","getTableCellLayout","theme","density","isLastColumn","isFirstColumn","spacing","basePaddingX","edgePaddingX","paddingLeft","paddingRight","typography","body2","padding","height","fontSize","body1","persesColumnsToTanstackColumns","columns","tableCols","map","width","align","headerDescription","cellDescription","enableSorting","otherProps","sizeProps","undefined","size","minSize","maxSize","result","meta"],"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;AA+HjC,SAASA,yBAAyBC,UAAuC,EAAEC,QAAgB;IACzF,6EAA6E;IAC7E,mDAAmD;IACnD,MAAMC,gBAAgB,OAAOF,eAAe,WAAWG,SAASH,YAAY,MAAMA,uBAAAA,wBAAAA,aAAc;IAChG,MAAMI,qBAAqB,OAAOH,aAAa,WAAWE,SAASF,UAAU,MAAMA;IAEnF,OAAOC,gBAAgBE,qBAAqB;AAC9C;AAWA;;;CAGC,GACD,OAAO,SAASC,mBACdC,KAAY,EACZC,OAAqB,EACrB,EAAEC,aAAY,EAAEC,cAAa,EAA0B,GAAG,CAAC,CAAC;IAE5D,IAAIF,YAAY,WAAW;QACzB,MAAM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,IACA;YACEF,MAAMR;QACR;QAEN,MAAMW,SAAS;YACb,GAAGN,UAAU;YACb,GAAGC,SAAS;YAEZ,qEAAqE;YACrEF,eAAe,CAAC,CAACA;YAEjB,yEAAyE;YACzE,wBAAwB;YACxBQ,MAAM;gBACJX;gBACAC;gBACAC;YACF;QACF;QAEA,OAAOQ;IACT;IAGF,OAAOb;AACT"}
@@ -25,7 +25,7 @@ export function ThresholdColorPicker({ color , onColorChange , label }) {
25
25
  const closeColorPicker = ()=>{
26
26
  setAnchorEl(null);
27
27
  };
28
- const { thresholds: { defaultColor , palette } , } = useChartsTheme();
28
+ const { thresholds: { defaultColor , palette } } = useChartsTheme();
29
29
  return /*#__PURE__*/ _jsxs(_Fragment, {
30
30
  children: [
31
31
  /*#__PURE__*/ _jsx(ColorIconButton, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdColorPicker.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 from 'react';\nimport { styled, IconButton, Popover } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { ColorPicker } from '../ColorPicker';\nimport { ThresholdInputProps } from './ThresholdInput';\n\nexport function ThresholdColorPicker({\n color,\n onColorChange,\n label,\n}: Pick<ThresholdInputProps, 'color' | 'onColorChange' | 'label'>) {\n const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);\n const isOpen = Boolean(anchorEl);\n\n const openColorPicker = (event: React.MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const closeColorPicker = () => {\n setAnchorEl(null);\n };\n\n const {\n thresholds: { defaultColor, palette },\n } = useChartsTheme();\n\n return (\n <>\n <ColorIconButton\n size=\"small\"\n aria-label={`change threshold ${label} color`}\n isSelected={isOpen}\n iconColor={color}\n onClick={openColorPicker}\n >\n <CircleIcon />\n </ColorIconButton>\n <Popover\n data-testid=\"threshold color picker\"\n open={isOpen}\n anchorEl={anchorEl}\n onClose={closeColorPicker}\n PaperProps={{ sx: { padding: (theme) => theme.spacing(2) } }}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <ColorPicker color={color} onChange={onColorChange} palette={[defaultColor, ...palette]} />\n </Popover>\n </>\n );\n}\n\nconst ColorIconButton = styled(IconButton, {\n shouldForwardProp: (props) => props !== 'isSelected' && props !== 'iconColor',\n})<{\n iconColor?: string;\n isSelected?: boolean;\n}>(({ iconColor, isSelected }) => ({\n backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined', // 3F represents 25% opacity\n color: iconColor,\n}));\n"],"names":["React","styled","IconButton","Popover","CircleIcon","useChartsTheme","ColorPicker","ThresholdColorPicker","color","onColorChange","label","anchorEl","setAnchorEl","useState","isOpen","Boolean","openColorPicker","event","currentTarget","closeColorPicker","thresholds","defaultColor","palette","ColorIconButton","size","aria-label","isSelected","iconColor","onClick","data-testid","open","onClose","PaperProps","sx","padding","theme","spacing","anchorOrigin","vertical","horizontal","transformOrigin","onChange","shouldForwardProp","props","backgroundColor"],"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,MAAM,OAAO,CAAC;AAC1B,SAASC,MAAM,EAAEC,UAAU,EAAE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qBAAE;iBAAE;gBAC5DC,YAAY,EAAE;oBACZC,QAAQ,EAAE,KAAK;oBACfC,UAAU,EAAE,MAAM;iBACnB;gBACDC,eAAe,EAAE;oBACfF,QAAQ,EAAE,KAAK;oBACfC,UAAU,EAAE,OAAO;iBACpB;0BAED,cAAA,KAACjC,WAAW;oBAACE,KAAK,EAAEA,KAAK;oBAAEiC,QAAQ,EAAEhC,aAAa;oBAAEa,OAAO,EAAE;wBAACD,YAAY;2BAAKC,OAAO;qBAAC;kBAAI;cACnF;;MACT,CACH;AACJ,CAAC;AAED,MAAMC,eAAe,GAAGtB,MAAM,CAACC,UAAU,EAAE;IACzCwC,iBAAiB,EAAE,CAACC,KAAK,GAAKA,KAAK,KAAK,YAAY,IAAIA,KAAK,KAAK,WAAW;CAC9E,CAAC,CAGC,CAAC,EAAEhB,SAAS,CAAA,EAAED,UAAU,CAAA,EAAE,GAAM,CAAA;QACjCkB,eAAe,EAAElB,UAAU,IAAIC,SAAS,GAAG,CAAC,EAAEA,SAAS,CAAC,EAAE,CAAC,GAAG,WAAW;QACzEnB,KAAK,EAAEmB,SAAS;KACjB,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdColorPicker.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 from 'react';\nimport { styled, IconButton, Popover } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { ColorPicker } from '../ColorPicker';\nimport { ThresholdInputProps } from './ThresholdInput';\n\nexport function ThresholdColorPicker({\n color,\n onColorChange,\n label,\n}: Pick<ThresholdInputProps, 'color' | 'onColorChange' | 'label'>) {\n const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);\n const isOpen = Boolean(anchorEl);\n\n const openColorPicker = (event: React.MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const closeColorPicker = () => {\n setAnchorEl(null);\n };\n\n const {\n thresholds: { defaultColor, palette },\n } = useChartsTheme();\n\n return (\n <>\n <ColorIconButton\n size=\"small\"\n aria-label={`change threshold ${label} color`}\n isSelected={isOpen}\n iconColor={color}\n onClick={openColorPicker}\n >\n <CircleIcon />\n </ColorIconButton>\n <Popover\n data-testid=\"threshold color picker\"\n open={isOpen}\n anchorEl={anchorEl}\n onClose={closeColorPicker}\n PaperProps={{ sx: { padding: (theme) => theme.spacing(2) } }}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <ColorPicker color={color} onChange={onColorChange} palette={[defaultColor, ...palette]} />\n </Popover>\n </>\n );\n}\n\nconst ColorIconButton = styled(IconButton, {\n shouldForwardProp: (props) => props !== 'isSelected' && props !== 'iconColor',\n})<{\n iconColor?: string;\n isSelected?: boolean;\n}>(({ iconColor, isSelected }) => ({\n backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined', // 3F represents 25% opacity\n color: iconColor,\n}));\n"],"names":["React","styled","IconButton","Popover","CircleIcon","useChartsTheme","ColorPicker","ThresholdColorPicker","color","onColorChange","label","anchorEl","setAnchorEl","useState","isOpen","Boolean","openColorPicker","event","currentTarget","closeColorPicker","thresholds","defaultColor","palette","ColorIconButton","size","aria-label","isSelected","iconColor","onClick","data-testid","open","onClose","PaperProps","sx","padding","theme","spacing","anchorOrigin","vertical","horizontal","transformOrigin","onChange","shouldForwardProp","props","backgroundColor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;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AUA,UAAU,gBAAgBA,UAAU;AACpE,GAGG,CAAC,EAAEhB,UAAS,EAAED,WAAU,EAAE,GAAM,CAAA;QACjCkB,iBAAiBlB,cAAcC,YAAY,CAAC,EAAEA,UAAU,EAAE,CAAC,GAAG;QAC9DnB,OAAOmB;IACT,CAAA"}
@@ -48,7 +48,7 @@ export function ThresholdInput({ inputRef , label , color , value , mode , onCha
48
48
  }
49
49
  },
50
50
  InputProps: {
51
- endAdornment: mode === 'Percent' ? /*#__PURE__*/ _jsx(Box, {
51
+ endAdornment: mode === 'percent' ? /*#__PURE__*/ _jsx(Box, {
52
52
  paddingX: 1,
53
53
  children: "%"
54
54
  }) : undefined
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdInput.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 { RefObject, useState } from 'react';\nimport { Stack, FormLabel, TextField, IconButton, Box } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { ThresholdOptions } from '@perses-dev/core';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\n\nexport interface ThresholdInputProps {\n label: string;\n color: string;\n value: number;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorChange: (color: string) => void;\n onBlur: () => void;\n onDelete: () => void;\n inputRef?: RefObject<HTMLInputElement | null>;\n mode?: ThresholdOptions['mode'];\n}\n\nexport function ThresholdInput({\n inputRef,\n label,\n color,\n value,\n mode,\n onChange,\n onColorChange,\n onBlur,\n onDelete,\n}: ThresholdInputProps) {\n const [key, setKey] = useState(0); // use key to cause input to lose focus when pressing enter\n return (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" spacing={1}>\n <ThresholdColorPicker label={label} color={color} onColorChange={onColorChange} />\n <FormLabel htmlFor={label}>{label}</FormLabel>\n <TextField\n id={label}\n key={key}\n inputRef={inputRef}\n type=\"number\"\n value={value === 0 ? '' : value}\n placeholder=\"0\"\n onChange={onChange}\n onBlur={onBlur}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onBlur();\n setKey(key + 1);\n }\n }}\n InputProps={{\n endAdornment: mode === 'Percent' ? <Box paddingX={1}>%</Box> : undefined,\n }}\n />\n <IconButton aria-label={`delete threshold ${label}`} size=\"small\" onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Stack>\n );\n}\n"],"names":["useState","Stack","FormLabel","TextField","IconButton","Box","DeleteIcon","ThresholdColorPicker","ThresholdInput","inputRef","label","color","value","mode","onChange","onColorChange","onBlur","onDelete","key","setKey","flex","direction","alignItems","justifyContent","spacing","htmlFor","id","type","placeholder","onKeyDown","e","InputProps","endAdornment","paddingX","undefined","aria-label","size","onClick"],"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,SAAoBA,QAAQ,QAAQ,OAAO,CAAC;AAC5C,SAASC,KAAK,EAAEC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,GAAG,QAAQ,eAAe,CAAC;AAC7E,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AAEvD,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAc9D,OAAO,SAASC,cAAc,CAAC,EAC7BC,QAAQ,CAAA,EACRC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,IAAI,CAAA,EACJC,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AACC,OAAO,EAAEpB,QAAQ;0BACjF,cAAA,KAACX,UAAU,KAAG;cACH;;MACP,CACR;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdInput.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 { RefObject, useState } from 'react';\nimport { Stack, FormLabel, TextField, IconButton, Box } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { ThresholdOptions } from '@perses-dev/core';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\n\nexport interface ThresholdInputProps {\n label: string;\n color: string;\n value: number;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorChange: (color: string) => void;\n onBlur: () => void;\n onDelete: () => void;\n inputRef?: RefObject<HTMLInputElement | null>;\n mode?: ThresholdOptions['mode'];\n}\n\nexport function ThresholdInput({\n inputRef,\n label,\n color,\n value,\n mode,\n onChange,\n onColorChange,\n onBlur,\n onDelete,\n}: ThresholdInputProps) {\n const [key, setKey] = useState(0); // use key to cause input to lose focus when pressing enter\n return (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" spacing={1}>\n <ThresholdColorPicker label={label} color={color} onColorChange={onColorChange} />\n <FormLabel htmlFor={label}>{label}</FormLabel>\n <TextField\n id={label}\n key={key}\n inputRef={inputRef}\n type=\"number\"\n value={value === 0 ? '' : value}\n placeholder=\"0\"\n onChange={onChange}\n onBlur={onBlur}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onBlur();\n setKey(key + 1);\n }\n }}\n InputProps={{\n endAdornment: mode === 'percent' ? <Box paddingX={1}>%</Box> : undefined,\n }}\n />\n <IconButton aria-label={`delete threshold ${label}`} size=\"small\" onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Stack>\n );\n}\n"],"names":["useState","Stack","FormLabel","TextField","IconButton","Box","DeleteIcon","ThresholdColorPicker","ThresholdInput","inputRef","label","color","value","mode","onChange","onColorChange","onBlur","onDelete","key","setKey","flex","direction","alignItems","justifyContent","spacing","htmlFor","id","type","placeholder","onKeyDown","e","InputProps","endAdornment","paddingX","undefined","aria-label","size","onClick"],"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,SAAoBA,QAAQ,QAAQ,QAAQ;AAC5C,SAASC,KAAK,EAAEC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,GAAG,QAAQ,gBAAgB;AAC7E,OAAOC,gBAAgB,gCAAgC;AAEvD,SAASC,oBAAoB,QAAQ,yBAAyB;AAc9D,OAAO,SAASC,eAAe,EAC7BC,SAAQ,EACRC,MAAK,EACLC,MAAK,EACLC,MAAK,EACLC,KAAI,EACJC,SAAQ,EACRC,cAAa,EACbC,OAAM,EACNC,SAAQ,EACY;IACpB,MAAM,CAACC,KAAKC,OAAO,GAAGnB,SAAS,IAAI,2DAA2D;IAC9F,qBACE,MAACC;QAAMmB,MAAM;QAAGC,WAAU;QAAMC,YAAW;QAASC,gBAAe;QAAgBC,SAAS;;0BAC1F,KAACjB;gBAAqBG,OAAOA;gBAAOC,OAAOA;gBAAOI,eAAeA;;0BACjE,KAACb;gBAAUuB,SAASf;0BAAQA;;0BAC5B,KAACP;gBACCuB,IAAIhB;gBAEJD,UAAUA;gBACVkB,MAAK;gBACLf,OAAOA,UAAU,IAAI,KAAKA;gBAC1BgB,aAAY;gBACZd,UAAUA;gBACVE,QAAQA;gBACRa,WAAW,CAACC;oBACV,IAAIA,EAAEZ,QAAQ,SAAS;wBACrBF;wBACAG,OAAOD,MAAM;oBACf;gBACF;gBACAa,YAAY;oBACVC,cAAcnB,SAAS,0BAAY,KAACR;wBAAI4B,UAAU;kCAAG;yBAAUC;gBACjE;eAfKhB;0BAiBP,KAACd;gBAAW+B,cAAY,CAAC,iBAAiB,EAAEzB,MAAM,CAAC;gBAAE0B,MAAK;gBAAQC,SAASpB;0BACzE,cAAA,KAACX;;;;AAIT"}
@@ -24,9 +24,9 @@ import { ThresholdInput } from './ThresholdInput';
24
24
  const DEFAULT_STEP = 10;
25
25
  export function ThresholdsEditor({ thresholds , onChange , hideDefault , disablePercentMode }) {
26
26
  const chartsTheme = useChartsTheme();
27
- const { thresholds: { defaultColor , palette } , } = chartsTheme;
28
- var ref;
29
- const defaultThresholdColor = (ref = thresholds === null || thresholds === void 0 ? void 0 : thresholds.default_color) !== null && ref !== void 0 ? ref : defaultColor;
27
+ const { thresholds: { defaultColor , palette } } = chartsTheme;
28
+ var _thresholds_defaultColor;
29
+ const defaultThresholdColor = (_thresholds_defaultColor = thresholds === null || thresholds === void 0 ? void 0 : thresholds.defaultColor) !== null && _thresholds_defaultColor !== void 0 ? _thresholds_defaultColor : defaultColor;
30
30
  const [steps, setSteps] = useState(thresholds === null || thresholds === void 0 ? void 0 : thresholds.steps);
31
31
  useEffect(()=>{
32
32
  setSteps(thresholds === null || thresholds === void 0 ? void 0 : thresholds.steps);
@@ -37,9 +37,9 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
37
37
  const recentlyAddedInputRef = useRef(null);
38
38
  const focusRef = useRef(false);
39
39
  useEffect(()=>{
40
- var ref;
40
+ var _recentlyAddedInputRef_current;
41
41
  if (!recentlyAddedInputRef.current || !focusRef.current) return;
42
- (ref = recentlyAddedInputRef.current) === null || ref === void 0 ? void 0 : ref.focus();
42
+ (_recentlyAddedInputRef_current = recentlyAddedInputRef.current) === null || _recentlyAddedInputRef_current === void 0 ? void 0 : _recentlyAddedInputRef_current.focus();
43
43
  focusRef.current = false;
44
44
  }, [
45
45
  steps === null || steps === void 0 ? void 0 : steps.length
@@ -67,11 +67,11 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
67
67
  const handleDefaultColorChange = (color)=>{
68
68
  if (thresholds !== undefined) {
69
69
  onChange(produce(thresholds, (draft)=>{
70
- draft.default_color = color;
70
+ draft.defaultColor = color;
71
71
  }));
72
72
  } else {
73
73
  onChange({
74
- default_color: color
74
+ defaultColor: color
75
75
  });
76
76
  }
77
77
  };
@@ -122,12 +122,12 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
122
122
  const steps = draft.steps;
123
123
  if (steps === null || steps === void 0 ? void 0 : steps.length) {
124
124
  const lastStep = steps[steps.length - 1];
125
- var _length;
126
- const color = (_length = palette[steps.length]) !== null && _length !== void 0 ? _length : getRandomColor(); // we will assign color from the palette first, then generate random color
127
- var ref;
125
+ var _palette_steps_length;
126
+ const color = (_palette_steps_length = palette[steps.length]) !== null && _palette_steps_length !== void 0 ? _palette_steps_length : getRandomColor(); // we will assign color from the palette first, then generate random color
127
+ var _lastStep_value;
128
128
  steps.push({
129
129
  color,
130
- value: ((ref = lastStep === null || lastStep === void 0 ? void 0 : lastStep.value) !== null && ref !== void 0 ? ref : 0) + DEFAULT_STEP
130
+ value: ((_lastStep_value = lastStep === null || lastStep === void 0 ? void 0 : lastStep.value) !== null && _lastStep_value !== void 0 ? _lastStep_value : 0) + DEFAULT_STEP
131
131
  }); // set new threshold value to last step value + 10
132
132
  } else if (steps) {
133
133
  steps.push({
@@ -138,7 +138,7 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
138
138
  }
139
139
  };
140
140
  const handleModeChange = (event, value)=>{
141
- const mode = value === 'Percent' ? 'Percent' : undefined;
141
+ const mode = value === 'percent' ? 'percent' : undefined;
142
142
  if (thresholds !== undefined) {
143
143
  onChange(produce(thresholds, (draft)=>{
144
144
  draft.mode = mode;
@@ -149,7 +149,7 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
149
149
  });
150
150
  }
151
151
  };
152
- var ref1, _color, ref2;
152
+ var _thresholds_mode, _step_color, _ref;
153
153
  return /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
154
154
  title: "Thresholds",
155
155
  icon: /*#__PURE__*/ _jsx(InfoTooltip, {
@@ -168,7 +168,7 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
168
168
  control: /*#__PURE__*/ _jsxs(ToggleButtonGroup, {
169
169
  exclusive: true,
170
170
  disabled: disablePercentMode,
171
- value: (ref1 = thresholds === null || thresholds === void 0 ? void 0 : thresholds.mode) !== null && ref1 !== void 0 ? ref1 : 'Absolute',
171
+ value: (_thresholds_mode = thresholds === null || thresholds === void 0 ? void 0 : thresholds.mode) !== null && _thresholds_mode !== void 0 ? _thresholds_mode : 'absolute',
172
172
  onChange: handleModeChange,
173
173
  sx: {
174
174
  height: '36px',
@@ -177,7 +177,7 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
177
177
  children: [
178
178
  /*#__PURE__*/ _jsx(ToggleButton, {
179
179
  "aria-label": "absolute",
180
- value: "Absolute",
180
+ value: "absolute",
181
181
  sx: {
182
182
  fontWeight: 500
183
183
  },
@@ -185,7 +185,7 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
185
185
  }),
186
186
  /*#__PURE__*/ _jsx(ToggleButton, {
187
187
  "aria-label": "percent",
188
- value: "Percent",
188
+ value: "percent",
189
189
  sx: {
190
190
  fontWeight: 500
191
191
  },
@@ -198,7 +198,7 @@ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disable
198
198
  /*#__PURE__*/ return _jsx(ThresholdInput, {
199
199
  inputRef: i === steps.length - 1 ? recentlyAddedInputRef : undefined,
200
200
  label: `T${i + 1}`,
201
- color: (ref2 = (_color = step.color) !== null && _color !== void 0 ? _color : palette[i]) !== null && ref2 !== void 0 ? ref2 : defaultThresholdColor,
201
+ color: (_ref = (_step_color = step.color) !== null && _step_color !== void 0 ? _step_color : palette[i]) !== null && _ref !== void 0 ? _ref : defaultThresholdColor,
202
202
  value: step.value,
203
203
  mode: thresholds === null || thresholds === void 0 ? void 0 : thresholds.mode,
204
204
  onColorChange: (color)=>handleThresholdColorChange(color, i),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdsEditor.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, { useEffect, useRef, useState } from 'react';\nimport produce from 'immer';\nimport { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { Stack } from '@mui/system';\nimport { ThresholdOptions } from '@perses-dev/core';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\nimport { ThresholdInput } from './ThresholdInput';\n\nexport interface ThresholdsEditorProps {\n onChange: (thresholds: ThresholdOptions) => void;\n thresholds?: ThresholdOptions;\n hideDefault?: boolean;\n disablePercentMode?: boolean;\n}\n\nconst DEFAULT_STEP = 10;\n\nexport function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }: ThresholdsEditorProps) {\n const chartsTheme = useChartsTheme();\n const {\n thresholds: { defaultColor, palette },\n } = chartsTheme;\n const defaultThresholdColor = thresholds?.default_color ?? defaultColor;\n\n const [steps, setSteps] = useState(thresholds?.steps);\n useEffect(() => {\n setSteps(thresholds?.steps);\n }, [thresholds?.steps]);\n\n // every time a new threshold is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [steps?.length]);\n\n const handleThresholdValueChange = (e: React.ChangeEvent<HTMLInputElement>, i: number) => {\n setSteps(\n produce(steps, (draft) => {\n const step = draft?.[i];\n if (step) {\n step.value = Number(e.target.value);\n }\n })\n );\n };\n\n const handleThresholdColorChange = (color: string, i: number) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n if (draft.steps !== undefined) {\n const step = draft.steps[i];\n if (step) {\n step.color = color;\n }\n }\n })\n );\n }\n };\n\n const handleDefaultColorChange = (color: string) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.default_color = color;\n })\n );\n } else {\n onChange({\n default_color: color,\n });\n }\n };\n\n // sort thresholds in ascending order every time an input blurs\n const handleThresholdBlur = () => {\n if (steps !== undefined) {\n const sortedSteps = [...steps];\n sortedSteps.sort((a, b) => a.value - b.value);\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = sortedSteps;\n })\n );\n }\n }\n };\n\n const deleteThreshold = (i: number): void => {\n if (thresholds !== undefined) {\n const updatedThresholds = produce(thresholds, (draft) => {\n if (draft.steps) {\n draft.steps.splice(i, 1);\n }\n });\n onChange(updatedThresholds);\n }\n };\n\n const addThresholdInput = (): void => {\n focusRef.current = true;\n if (thresholds === undefined) {\n onChange({\n steps: [{ value: DEFAULT_STEP }],\n });\n } else if (thresholds && thresholds.steps === undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = [{ value: DEFAULT_STEP }];\n })\n );\n } else {\n onChange(\n produce(thresholds, (draft) => {\n const steps = draft.steps;\n if (steps?.length) {\n const lastStep = steps[steps.length - 1];\n const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color\n steps.push({ color, value: (lastStep?.value ?? 0) + DEFAULT_STEP }); // set new threshold value to last step value + 10\n } else if (steps) {\n steps.push({ value: DEFAULT_STEP });\n }\n })\n );\n }\n };\n\n const handleModeChange = (event: React.MouseEvent, value: string): void => {\n const mode = value === 'Percent' ? 'Percent' : undefined;\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.mode = mode;\n })\n );\n } else {\n onChange({ mode });\n }\n };\n\n return (\n <OptionsEditorGroup\n title=\"Thresholds\"\n icon={\n <InfoTooltip description={'Add threshold'}>\n <IconButton size=\"small\" aria-label=\"add threshold\" onClick={addThresholdInput}>\n <PlusIcon />\n </IconButton>\n </InfoTooltip>\n }\n >\n <OptionsEditorControl\n label=\"Mode\"\n description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n disabled={disablePercentMode}\n value={thresholds?.mode ?? 'Absolute'}\n onChange={handleModeChange}\n sx={{ height: '36px', marginLeft: 'auto' }}\n >\n <ToggleButton aria-label=\"absolute\" value=\"Absolute\" sx={{ fontWeight: 500 }}>\n Absolute\n </ToggleButton>\n <ToggleButton aria-label=\"percent\" value=\"Percent\" sx={{ fontWeight: 500 }}>\n Percent\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {steps &&\n steps\n .map((step, i) => (\n <ThresholdInput\n inputRef={i === steps.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n label={`T${i + 1}`}\n color={step.color ?? palette[i] ?? defaultThresholdColor}\n value={step.value}\n mode={thresholds?.mode}\n onColorChange={(color) => handleThresholdColorChange(color, i)}\n onChange={(e) => {\n handleThresholdValueChange(e, i);\n }}\n onDelete={() => {\n deleteThreshold(i);\n }}\n onBlur={handleThresholdBlur}\n />\n ))\n .reverse()}\n {!hideDefault && (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" spacing={1}>\n <ThresholdColorPicker\n label=\"default\"\n color={defaultThresholdColor}\n onColorChange={handleDefaultColorChange}\n />\n <Typography>Default</Typography>\n </Stack>\n )}\n </OptionsEditorGroup>\n );\n}\n\n// https://www.paulirish.com/2009/random-hex-color-code-snippets/\nconst getRandomColor = () => {\n return (\n '#' +\n Math.floor(Math.random() * 16777216)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"names":["React","useEffect","useRef","useState","produce","IconButton","ToggleButton","ToggleButtonGroup","Typography","PlusIcon","Stack","useChartsTheme","OptionsEditorControl","OptionsEditorGroup","InfoTooltip","ThresholdColorPicker","ThresholdInput","DEFAULT_STEP","ThresholdsEditor","thresholds","onChange","hideDefault","disablePercentMode","chartsTheme","defaultColor","palette","defaultThresholdColor","default_color","steps","setSteps","recentlyAddedInputRef","focusRef","current","focus","length","handleThresholdValueChange","e","i","draft","step","value","Number","target","handleThresholdColorChange","color","undefined","handleDefaultColorChange","handleThresholdBlur","sortedSteps","sort","a","b","deleteThreshold","updatedThresholds","splice","addThresholdInput","lastStep","getRandomColor","push","handleModeChange","event","mode","title","icon","description","size","aria-label","onClick","label","control","exclusive","disabled","sx","height","marginLeft","fontWeight","map","inputRef","onColorChange","onDelete","onBlur","reverse","flex","direction","alignItems","spacing","Math","floor","random","toString","padStart"],"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,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC3D,OAAOC,OAAO,MAAM,OAAO,CAAC;AAC5B,SAASC,UAAU,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACxF,OAAOC,QAAQ,MAAM,sBAAsB,CAAC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GAAKD,0BAA0B,CAACC,KAAK,EAAEP,CAAC,CAAC;oBAC9DjB,QAAQ,EAAE,CAACgB,CAAC,GAAK;wBACfD,0BAA0B,CAACC,CAAC,EAAEC,CAAC,CAAC,CAAC;oBACnC,CAAC;oBACD0C,QAAQ,EAAE,IAAM;wBACd3B,eAAe,CAACf,CAAC,CAAC,CAAC;oBACrB,CAAC;oBACD2C,MAAM,EAAEjC,mBAAmB;mBAZtBV,CAAC,CAaN,CAAA;aACH,CAAC,CACD4C,OAAO,EAAE;YACb,CAAC5D,WAAW,kBACX,MAACX,KAAK;gBAACwE,IAAI,EAAE,CAAC;gBAAEC,SAAS,EAAC,KAAK;gBAACC,UAAU,EAAC,QAAQ;gBAACC,OAAO,EAAE,CAAC;;kCAC5D,KAACtE,oBAAoB;wBACnBqD,KAAK,EAAC,SAAS;wBACfxB,KAAK,EAAElB,qBAAqB;wBAC5BoD,aAAa,EAAEhC,wBAAwB;sBACvC;kCACF,KAACtC,UAAU;kCAAC,SAAO;sBAAa;;cAC1B,AACT;;MACkB,CACrB;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAMiD,cAAc,GAAG,IAAM;IAC3B,OACE,GAAG,GACH6B,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,EAAE,GAAG,QAAQ,CAAC,CACjCC,QAAQ,CAAC,EAAE,CAAC,CACZC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CACnB;AACJ,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdsEditor.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, { useEffect, useRef, useState } from 'react';\nimport produce from 'immer';\nimport { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { Stack } from '@mui/system';\nimport { ThresholdOptions } from '@perses-dev/core';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\nimport { ThresholdInput } from './ThresholdInput';\n\nexport interface ThresholdsEditorProps {\n onChange: (thresholds: ThresholdOptions) => void;\n thresholds?: ThresholdOptions;\n hideDefault?: boolean;\n disablePercentMode?: boolean;\n}\n\nconst DEFAULT_STEP = 10;\n\nexport function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }: ThresholdsEditorProps) {\n const chartsTheme = useChartsTheme();\n const {\n thresholds: { defaultColor, palette },\n } = chartsTheme;\n const defaultThresholdColor = thresholds?.defaultColor ?? defaultColor;\n\n const [steps, setSteps] = useState(thresholds?.steps);\n useEffect(() => {\n setSteps(thresholds?.steps);\n }, [thresholds?.steps]);\n\n // every time a new threshold is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [steps?.length]);\n\n const handleThresholdValueChange = (e: React.ChangeEvent<HTMLInputElement>, i: number) => {\n setSteps(\n produce(steps, (draft) => {\n const step = draft?.[i];\n if (step) {\n step.value = Number(e.target.value);\n }\n })\n );\n };\n\n const handleThresholdColorChange = (color: string, i: number) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n if (draft.steps !== undefined) {\n const step = draft.steps[i];\n if (step) {\n step.color = color;\n }\n }\n })\n );\n }\n };\n\n const handleDefaultColorChange = (color: string) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.defaultColor = color;\n })\n );\n } else {\n onChange({\n defaultColor: color,\n });\n }\n };\n\n // sort thresholds in ascending order every time an input blurs\n const handleThresholdBlur = () => {\n if (steps !== undefined) {\n const sortedSteps = [...steps];\n sortedSteps.sort((a, b) => a.value - b.value);\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = sortedSteps;\n })\n );\n }\n }\n };\n\n const deleteThreshold = (i: number): void => {\n if (thresholds !== undefined) {\n const updatedThresholds = produce(thresholds, (draft) => {\n if (draft.steps) {\n draft.steps.splice(i, 1);\n }\n });\n onChange(updatedThresholds);\n }\n };\n\n const addThresholdInput = (): void => {\n focusRef.current = true;\n if (thresholds === undefined) {\n onChange({\n steps: [{ value: DEFAULT_STEP }],\n });\n } else if (thresholds && thresholds.steps === undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = [{ value: DEFAULT_STEP }];\n })\n );\n } else {\n onChange(\n produce(thresholds, (draft) => {\n const steps = draft.steps;\n if (steps?.length) {\n const lastStep = steps[steps.length - 1];\n const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color\n steps.push({ color, value: (lastStep?.value ?? 0) + DEFAULT_STEP }); // set new threshold value to last step value + 10\n } else if (steps) {\n steps.push({ value: DEFAULT_STEP });\n }\n })\n );\n }\n };\n\n const handleModeChange = (event: React.MouseEvent, value: string): void => {\n const mode = value === 'percent' ? 'percent' : undefined;\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.mode = mode;\n })\n );\n } else {\n onChange({ mode });\n }\n };\n\n return (\n <OptionsEditorGroup\n title=\"Thresholds\"\n icon={\n <InfoTooltip description={'Add threshold'}>\n <IconButton size=\"small\" aria-label=\"add threshold\" onClick={addThresholdInput}>\n <PlusIcon />\n </IconButton>\n </InfoTooltip>\n }\n >\n <OptionsEditorControl\n label=\"Mode\"\n description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n disabled={disablePercentMode}\n value={thresholds?.mode ?? 'absolute'}\n onChange={handleModeChange}\n sx={{ height: '36px', marginLeft: 'auto' }}\n >\n <ToggleButton aria-label=\"absolute\" value=\"absolute\" sx={{ fontWeight: 500 }}>\n Absolute\n </ToggleButton>\n <ToggleButton aria-label=\"percent\" value=\"percent\" sx={{ fontWeight: 500 }}>\n Percent\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {steps &&\n steps\n .map((step, i) => (\n <ThresholdInput\n inputRef={i === steps.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n label={`T${i + 1}`}\n color={step.color ?? palette[i] ?? defaultThresholdColor}\n value={step.value}\n mode={thresholds?.mode}\n onColorChange={(color) => handleThresholdColorChange(color, i)}\n onChange={(e) => {\n handleThresholdValueChange(e, i);\n }}\n onDelete={() => {\n deleteThreshold(i);\n }}\n onBlur={handleThresholdBlur}\n />\n ))\n .reverse()}\n {!hideDefault && (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" spacing={1}>\n <ThresholdColorPicker\n label=\"default\"\n color={defaultThresholdColor}\n onColorChange={handleDefaultColorChange}\n />\n <Typography>Default</Typography>\n </Stack>\n )}\n </OptionsEditorGroup>\n );\n}\n\n// https://www.paulirish.com/2009/random-hex-color-code-snippets/\nconst getRandomColor = () => {\n return (\n '#' +\n Math.floor(Math.random() * 16777216)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"names":["React","useEffect","useRef","useState","produce","IconButton","ToggleButton","ToggleButtonGroup","Typography","PlusIcon","Stack","useChartsTheme","OptionsEditorControl","OptionsEditorGroup","InfoTooltip","ThresholdColorPicker","ThresholdInput","DEFAULT_STEP","ThresholdsEditor","thresholds","onChange","hideDefault","disablePercentMode","chartsTheme","defaultColor","palette","defaultThresholdColor","steps","setSteps","recentlyAddedInputRef","focusRef","current","focus","length","handleThresholdValueChange","e","i","draft","step","value","Number","target","handleThresholdColorChange","color","undefined","handleDefaultColorChange","handleThresholdBlur","sortedSteps","sort","a","b","deleteThreshold","updatedThresholds","splice","addThresholdInput","lastStep","getRandomColor","push","handleModeChange","event","mode","title","icon","description","size","aria-label","onClick","label","control","exclusive","disabled","sx","height","marginLeft","fontWeight","map","inputRef","onColorChange","onDelete","onBlur","reverse","flex","direction","alignItems","spacing","Math","floor","random","toString","padStart"],"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,OAAOA,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC3D,OAAOC,aAAa,QAAQ;AAC5B,SAASC,UAAU,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,gBAAgB;AACxF,OAAOC,cAAc,uBAAuB;AAC5C,SAASC,KAAK,QAAQ,cAAc;AAEpC,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAClF,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,cAAc,QAAQ,mBAAmB;AASlD,MAAMC,eAAe;AAErB,OAAO,SAASC,iBAAiB,EAAEC,WAAU,EAAEC,SAAQ,EAAEC,YAAW,EAAEC,mBAAkB,EAAyB;IAC/G,MAAMC,cAAcZ;IACpB,MAAM,EACJQ,YAAY,EAAEK,aAAY,EAAEC,QAAO,EAAE,CAAA,EACtC,GAAGF;QAC0BJ;IAA9B,MAAMO,wBAAwBP,CAAAA,2BAAAA,uBAAAA,wBAAAA,KAAAA,IAAAA,WAAYK,0BAAZL,sCAAAA,2BAA4BK;IAE1D,MAAM,CAACG,OAAOC,SAAS,GAAGzB,SAASgB,uBAAAA,wBAAAA,K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MzC,uBAAAA,wBAAAA,KAAAA,IAAAA,WAAYyC;oBAClBiB,eAAe,CAAClC,QAAUD,2BAA2BC,OAAOP;oBAC5DhB,UAAU,CAACe;wBACTD,2BAA2BC,GAAGC;oBAChC;oBACA0C,UAAU;wBACR3B,gBAAgBf;oBAClB;oBACA2C,QAAQjC;mBAZHV;eAeR4C;YACJ,CAAC3D,6BACA,MAACX;gBAAMuE,MAAM;gBAAGC,WAAU;gBAAMC,YAAW;gBAASC,SAAS;;kCAC3D,KAACrE;wBACCoD,OAAM;wBACNxB,OAAOjB;wBACPmD,eAAehC;;kCAEjB,KAACrC;kCAAW;;;;;;AAKtB;AAEA,iEAAiE;AACjE,MAAMgD,iBAAiB;IACrB,OACE,MACA6B,KAAKC,MAAMD,KAAKE,WAAW,UACxBC,SAAS,IACTC,SAAS,GAAG;AAEnB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ThresholdsEditor/index.ts"],"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\nexport * from './ThresholdsEditor';\n"],"names":[],"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,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/index.ts"],"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\nexport * from './ThresholdsEditor';\n"],"names":[],"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,cAAc,qBAAqB"}
@@ -1,5 +1,5 @@
1
1
  import { MouseEvent } from 'react';
2
- import { TimeScale, UnitOptions, TimeSeries } from '@perses-dev/core';
2
+ import { TimeScale, FormatOptions, TimeSeries } from '@perses-dev/core';
3
3
  import type { EChartsCoreOption, GridComponentOption, YAXisComponentOption } from 'echarts';
4
4
  import { ChartInstance, TimeChartSeriesMapping } from '../model';
5
5
  import { ZoomEventData } from '../utils';
@@ -10,7 +10,7 @@ export interface TimeChartProps {
10
10
  seriesMapping: TimeChartSeriesMapping;
11
11
  timeScale?: TimeScale;
12
12
  yAxis?: YAXisComponentOption;
13
- unit?: UnitOptions;
13
+ format?: FormatOptions;
14
14
  grid?: GridComponentOption;
15
15
  tooltipConfig?: TooltipConfig;
16
16
  noDataVariant?: 'chart' | 'message';
@@ -1 +1 @@
1
- {"version":3,"file":"TimeChart.d.ts","sourceRoot":"","sources":["../../src/TimeChart/TimeChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,UAAU,EAA6D,MAAM,OAAO,CAAC;AAM1G,OAAO,EAAsB,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAgBjB,O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AAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAuC,aAAa,EAA0B,MAAM,sBAAsB,CAAC;AAkBlH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,aAAa,EAAE,sBAAsB,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,oCAAoC,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,iBAAiB,CAAC;CAC1F;AAED,eAAO,MAAM,SAAS,0GA8WpB,CAAC"}
@@ -41,8 +41,8 @@ use([
41
41
  TooltipComponent,
42
42
  CanvasRenderer
43
43
  ]);
44
- export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height , data , seriesMapping , timeScale: timeScaleProp , yAxis , unit , grid , isStackedBar =false , tooltipConfig =DEFAULT_TOOLTIP_CONFIG , noDataVariant ='message' , syncGroup , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride , }, ref) {
45
- var ref1;
44
+ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height , data , seriesMapping , timeScale: timeScaleProp , yAxis , format , grid , isStackedBar =false , tooltipConfig =DEFAULT_TOOLTIP_CONFIG , noDataVariant ='message' , syncGroup , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride }, ref) {
45
+ var _option_tooltip;
46
46
  const { chartsTheme , enablePinning , lastTooltipPinnedCoords , setLastTooltipPinnedCoords } = useChartsContext();
47
47
  const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;
48
48
  const chartRef = useRef();
@@ -52,8 +52,8 @@ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height ,
52
52
  const [isDragging, setIsDragging] = useState(false);
53
53
  const [startX, setStartX] = useState(0);
54
54
  const { timeZone } = useTimeZone();
55
- var ref2;
56
- const totalSeries = (ref2 = data === null || data === void 0 ? void 0 : data.length) !== null && ref2 !== void 0 ? ref2 : 0;
55
+ var _data_length;
56
+ const totalSeries = (_data_length = data === null || data === void 0 ? void 0 : data.length) !== null && _data_length !== void 0 ? _data_length : 0;
57
57
  let timeScale;
58
58
  if (timeScaleProp === undefined) {
59
59
  const commonTimeScale = getCommonTimeScale(data);
@@ -161,7 +161,7 @@ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height ,
161
161
  ...seriesMapping,
162
162
  pinnedCrosshair
163
163
  ] : seriesMapping;
164
- var _rangeMs;
164
+ var _timeScale_rangeMs;
165
165
  const option = {
166
166
  dataset: dataset,
167
167
  series: updatedSeriesMapping,
@@ -171,13 +171,13 @@ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height ,
171
171
  max: isLocalTimeZone ? timeScale.endMs : utcToZonedTime(timeScale.endMs, timeZone),
172
172
  axisLabel: {
173
173
  hideOverlap: true,
174
- formatter: getFormattedAxisLabel((_rangeMs = timeScale.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : 0)
174
+ formatter: getFormattedAxisLabel((_timeScale_rangeMs = timeScale.rangeMs) !== null && _timeScale_rangeMs !== void 0 ? _timeScale_rangeMs : 0)
175
175
  },
176
176
  axisPointer: {
177
177
  snap: false
178
178
  }
179
179
  },
180
- yAxis: getFormattedAxis(yAxis, unit),
180
+ yAxis: getFormattedAxis(yAxis, format),
181
181
  animation: false,
182
182
  tooltip: {
183
183
  show: true,
@@ -214,7 +214,7 @@ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height ,
214
214
  seriesMapping,
215
215
  timeScale,
216
216
  yAxis,
217
- unit,
217
+ format,
218
218
  grid,
219
219
  noDataOption,
220
220
  __experimentalEChartsOptionsOverride,
@@ -291,10 +291,10 @@ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height ,
291
291
  setPinnedCrosshair((current)=>{
292
292
  // Only add pinned crosshair line series when there is not one already in seriesMapping.
293
293
  if (current === null) {
294
- var ref;
294
+ var _data_;
295
295
  const cursorX = pointInGrid[0];
296
296
  // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent
297
- const firstTimeSeriesValues = (ref = data[0]) === null || ref === void 0 ? void 0 : ref.values;
297
+ const firstTimeSeriesValues = (_data_ = data[0]) === null || _data_ === void 0 ? void 0 : _data_.values;
298
298
  const closestTimestamp = getClosestTimestamp(firstTimeSeriesValues, cursorX);
299
299
  // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right
300
300
  const pinnedCrosshair = merge({}, DEFAULT_PINNED_CROSSHAIR, {
@@ -367,7 +367,7 @@ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height ,
367
367
  }
368
368
  },
369
369
  children: [
370
- showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(TimeChartTooltip, {
370
+ showTooltip === true && ((_option_tooltip = option.tooltip) === null || _option_tooltip === void 0 ? void 0 : _option_tooltip.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(TimeChartTooltip, {
371
371
  containerId: chartsTheme.tooltipPortalContainerId,
372
372
  chartRef: chartRef,
373
373
  data: data,
@@ -375,7 +375,7 @@ export const TimeChart = /*#__PURE__*/ forwardRef(function TimeChart({ height ,
375
375
  wrapLabels: tooltipConfig.wrapLabels,
376
376
  enablePinning: isPinningEnabled,
377
377
  pinnedPos: tooltipPinnedCoords,
378
- unit: unit,
378
+ format: format,
379
379
  onUnpinClick: ()=>{
380
380
  // Unpins tooltip when clicking Pin icon in TooltipHeader.
381
381
  setTooltipPinnedCoords(null);