@perses-dev/components 0.21.1 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/README.md +2 -3
  2. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts +2 -1
  3. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -1
  4. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js +88 -51
  5. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -1
  6. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
  7. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +3 -2
  8. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  9. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
  10. package/dist/DateTimeRangePicker/TimeRangeSelector.js +4 -1
  11. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  12. package/dist/DateTimeRangePicker/index.js +1 -1
  13. package/dist/DateTimeRangePicker/index.js.map +1 -1
  14. package/dist/DateTimeRangePicker/utils.js +1 -1
  15. package/dist/DateTimeRangePicker/utils.js.map +1 -1
  16. package/dist/Dialog/Dialog.d.ts +24 -0
  17. package/dist/Dialog/Dialog.d.ts.map +1 -0
  18. package/dist/Dialog/Dialog.js +74 -0
  19. package/dist/Dialog/Dialog.js.map +1 -0
  20. package/dist/Dialog/index.d.ts +2 -0
  21. package/dist/Dialog/index.d.ts.map +1 -0
  22. package/dist/{Tooltip → Dialog}/index.js +2 -3
  23. package/dist/{Tooltip → Dialog}/index.js.map +1 -1
  24. package/dist/Drawer/Drawer.js +1 -1
  25. package/dist/Drawer/Drawer.js.map +1 -1
  26. package/dist/Drawer/index.js +1 -1
  27. package/dist/Drawer/index.js.map +1 -1
  28. package/dist/EChart.js +1 -1
  29. package/dist/EChart.js.map +1 -1
  30. package/dist/ErrorAlert.js +1 -1
  31. package/dist/ErrorAlert.js.map +1 -1
  32. package/dist/ErrorBoundary.js +1 -1
  33. package/dist/ErrorBoundary.js.map +1 -1
  34. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  35. package/dist/GaugeChart/GaugeChart.js +5 -10
  36. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  37. package/dist/GaugeChart/index.js +1 -1
  38. package/dist/GaugeChart/index.js.map +1 -1
  39. package/dist/InfoTooltip/InfoTooltip.d.ts +1 -6
  40. package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -1
  41. package/dist/InfoTooltip/InfoTooltip.js +2 -9
  42. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  43. package/dist/InfoTooltip/InfoTooltip.test.js +1 -1
  44. package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -1
  45. package/dist/InfoTooltip/index.js +1 -1
  46. package/dist/InfoTooltip/index.js.map +1 -1
  47. package/dist/JSONEditor.d.ts +5 -4
  48. package/dist/JSONEditor.d.ts.map +1 -1
  49. package/dist/JSONEditor.js +21 -16
  50. package/dist/JSONEditor.js.map +1 -1
  51. package/dist/Legend/CompactLegend.js +1 -1
  52. package/dist/Legend/CompactLegend.js.map +1 -1
  53. package/dist/Legend/Legend.d.ts.map +1 -1
  54. package/dist/Legend/Legend.js +18 -6
  55. package/dist/Legend/Legend.js.map +1 -1
  56. package/dist/Legend/LegendColorBadge.js +1 -1
  57. package/dist/Legend/LegendColorBadge.js.map +1 -1
  58. package/dist/Legend/ListLegend.js +1 -1
  59. package/dist/Legend/ListLegend.js.map +1 -1
  60. package/dist/Legend/ListLegendItem.js +1 -1
  61. package/dist/Legend/ListLegendItem.js.map +1 -1
  62. package/dist/Legend/index.js +1 -1
  63. package/dist/Legend/index.js.map +1 -1
  64. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  65. package/dist/LegendOptionsEditor/LegendOptionsEditor.js +13 -18
  66. package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  67. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js +23 -2
  68. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js.map +1 -1
  69. package/dist/LegendOptionsEditor/index.js +1 -1
  70. package/dist/LegendOptionsEditor/index.js.map +1 -1
  71. package/dist/LineChart/LineChart.js +3 -3
  72. package/dist/LineChart/LineChart.js.map +1 -1
  73. package/dist/LineChart/index.js +1 -1
  74. package/dist/LineChart/index.js.map +1 -1
  75. package/dist/LineChart/utils.js +1 -1
  76. package/dist/LineChart/utils.js.map +1 -1
  77. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
  78. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  79. package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  80. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  81. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
  82. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  83. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
  84. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  85. package/dist/OptionsEditorLayout/index.js +1 -1
  86. package/dist/OptionsEditorLayout/index.js.map +1 -1
  87. package/dist/StatChart/StatChart.d.ts.map +1 -1
  88. package/dist/StatChart/StatChart.js +21 -12
  89. package/dist/StatChart/StatChart.js.map +1 -1
  90. package/dist/StatChart/StatChart.test.js +1 -1
  91. package/dist/StatChart/StatChart.test.js.map +1 -1
  92. package/dist/StatChart/index.js +1 -1
  93. package/dist/StatChart/index.js.map +1 -1
  94. package/dist/{Tooltip → TimeSeriesTooltip}/SeriesInfo.d.ts +1 -2
  95. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -0
  96. package/dist/TimeSeriesTooltip/SeriesInfo.js +89 -0
  97. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -0
  98. package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts +2 -0
  99. package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts.map +1 -0
  100. package/dist/TimeSeriesTooltip/SeriesInfo.test.js +52 -0
  101. package/dist/TimeSeriesTooltip/SeriesInfo.test.js.map +1 -0
  102. package/dist/TimeSeriesTooltip/SeriesLabelsStack.d.ts +9 -0
  103. package/dist/TimeSeriesTooltip/SeriesLabelsStack.d.ts.map +1 -0
  104. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +99 -0
  105. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -0
  106. package/dist/{Tooltip → TimeSeriesTooltip}/SeriesMarker.d.ts +2 -1
  107. package/dist/TimeSeriesTooltip/SeriesMarker.d.ts.map +1 -0
  108. package/dist/{Tooltip → TimeSeriesTooltip}/SeriesMarker.js +7 -7
  109. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -0
  110. package/dist/{Tooltip/Tooltip.d.ts → TimeSeriesTooltip/TimeSeriesTooltip.d.ts} +4 -4
  111. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -0
  112. package/dist/{Tooltip/Tooltip.js → TimeSeriesTooltip/TimeSeriesTooltip.js} +3 -4
  113. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -0
  114. package/dist/{Tooltip → TimeSeriesTooltip}/TooltipContent.d.ts +1 -2
  115. package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -0
  116. package/dist/{Tooltip → TimeSeriesTooltip}/TooltipContent.js +1 -1
  117. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -0
  118. package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts +2 -0
  119. package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts.map +1 -0
  120. package/dist/TimeSeriesTooltip/TooltipContent.test.js +78 -0
  121. package/dist/TimeSeriesTooltip/TooltipContent.test.js.map +1 -0
  122. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.d.ts +0 -0
  123. package/dist/TimeSeriesTooltip/focused-series.d.ts.map +1 -0
  124. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.js +3 -3
  125. package/dist/TimeSeriesTooltip/focused-series.js.map +1 -0
  126. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.test.d.ts +0 -0
  127. package/dist/TimeSeriesTooltip/focused-series.test.d.ts.map +1 -0
  128. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.test.js +1 -1
  129. package/dist/TimeSeriesTooltip/focused-series.test.js.map +1 -0
  130. package/dist/TimeSeriesTooltip/index.d.ts +9 -0
  131. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -0
  132. package/dist/TimeSeriesTooltip/index.js +22 -0
  133. package/dist/TimeSeriesTooltip/index.js.map +1 -0
  134. package/dist/{Tooltip → TimeSeriesTooltip}/tooltip-model.d.ts +0 -0
  135. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -0
  136. package/dist/{Tooltip → TimeSeriesTooltip}/tooltip-model.js +1 -1
  137. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -0
  138. package/dist/{Tooltip → TimeSeriesTooltip}/utils.d.ts +0 -0
  139. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -0
  140. package/dist/{Tooltip → TimeSeriesTooltip}/utils.js +1 -1
  141. package/dist/TimeSeriesTooltip/utils.js.map +1 -0
  142. package/dist/UnitSelector/UnitSelector.js +1 -1
  143. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  144. package/dist/UnitSelector/UnitSelector.test.js +1 -1
  145. package/dist/UnitSelector/UnitSelector.test.js.map +1 -1
  146. package/dist/UnitSelector/index.js +1 -1
  147. package/dist/UnitSelector/index.js.map +1 -1
  148. package/dist/YAxisLabel.js +1 -1
  149. package/dist/YAxisLabel.js.map +1 -1
  150. package/dist/cjs/DateTimeRangePicker/AbsoluteTimePicker.js +87 -50
  151. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +3 -2
  152. package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +4 -1
  153. package/dist/cjs/DateTimeRangePicker/index.js +1 -1
  154. package/dist/cjs/DateTimeRangePicker/utils.js +1 -1
  155. package/dist/cjs/Dialog/Dialog.js +85 -0
  156. package/dist/cjs/{Tooltip → Dialog}/index.js +2 -3
  157. package/dist/cjs/Drawer/Drawer.js +1 -1
  158. package/dist/cjs/Drawer/index.js +1 -1
  159. package/dist/cjs/EChart.js +1 -1
  160. package/dist/cjs/ErrorAlert.js +1 -1
  161. package/dist/cjs/ErrorBoundary.js +1 -1
  162. package/dist/cjs/GaugeChart/GaugeChart.js +5 -10
  163. package/dist/cjs/GaugeChart/index.js +1 -1
  164. package/dist/cjs/InfoTooltip/InfoTooltip.js +5 -18
  165. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +1 -1
  166. package/dist/cjs/InfoTooltip/index.js +1 -1
  167. package/dist/cjs/JSONEditor.js +25 -15
  168. package/dist/cjs/Legend/CompactLegend.js +1 -1
  169. package/dist/cjs/Legend/Legend.js +17 -5
  170. package/dist/cjs/Legend/LegendColorBadge.js +1 -1
  171. package/dist/cjs/Legend/ListLegend.js +1 -1
  172. package/dist/cjs/Legend/ListLegendItem.js +1 -1
  173. package/dist/cjs/Legend/index.js +1 -1
  174. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +13 -18
  175. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.test.js +23 -2
  176. package/dist/cjs/LegendOptionsEditor/index.js +1 -1
  177. package/dist/cjs/LineChart/LineChart.js +3 -3
  178. package/dist/cjs/LineChart/index.js +1 -1
  179. package/dist/cjs/LineChart/utils.js +1 -1
  180. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
  181. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  182. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
  183. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
  184. package/dist/cjs/OptionsEditorLayout/index.js +1 -1
  185. package/dist/cjs/StatChart/StatChart.js +21 -12
  186. package/dist/cjs/StatChart/StatChart.test.js +1 -1
  187. package/dist/cjs/StatChart/index.js +1 -1
  188. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +95 -0
  189. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.test.js +54 -0
  190. package/dist/cjs/TimeSeriesTooltip/SeriesLabelsStack.js +105 -0
  191. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/SeriesMarker.js +7 -7
  192. package/dist/cjs/{Tooltip/Tooltip.js → TimeSeriesTooltip/TimeSeriesTooltip.js} +4 -4
  193. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/TooltipContent.js +1 -1
  194. package/dist/cjs/TimeSeriesTooltip/TooltipContent.test.js +80 -0
  195. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/focused-series.js +3 -3
  196. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/focused-series.test.js +1 -1
  197. package/dist/cjs/TimeSeriesTooltip/index.js +35 -0
  198. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/tooltip-model.js +1 -1
  199. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/utils.js +1 -1
  200. package/dist/cjs/UnitSelector/UnitSelector.js +1 -1
  201. package/dist/cjs/UnitSelector/UnitSelector.test.js +1 -1
  202. package/dist/cjs/UnitSelector/index.js +1 -1
  203. package/dist/cjs/YAxisLabel.js +1 -1
  204. package/dist/cjs/context/ChartsThemeProvider.js +1 -1
  205. package/dist/cjs/context/TimeZoneProvider.js +1 -1
  206. package/dist/cjs/index.js +3 -1
  207. package/dist/cjs/model/graph.js +4 -15
  208. package/dist/cjs/model/index.js +2 -1
  209. package/dist/cjs/model/legend.js +67 -0
  210. package/dist/cjs/model/legend.test.js +29 -0
  211. package/dist/cjs/model/theme.js +1 -1
  212. package/dist/cjs/model/units/bytes.js +1 -1
  213. package/dist/cjs/model/units/constants.js +1 -1
  214. package/dist/cjs/model/units/decimal.js +5 -2
  215. package/dist/cjs/model/units/index.js +1 -1
  216. package/dist/cjs/model/units/percent.js +1 -1
  217. package/dist/cjs/model/units/time.js +1 -1
  218. package/dist/cjs/model/units/types.js +1 -1
  219. package/dist/cjs/model/units/units.js +1 -1
  220. package/dist/cjs/model/units/units.test.js +59 -6
  221. package/dist/cjs/test/index.js +1 -1
  222. package/dist/cjs/test/render.js +1 -1
  223. package/dist/cjs/test/setup-tests.js +1 -1
  224. package/dist/cjs/test-utils/index.js +1 -1
  225. package/dist/cjs/test-utils/theme.js +6 -1
  226. package/dist/cjs/theme/index.js +1 -1
  227. package/dist/cjs/theme/palette/background.js +1 -1
  228. package/dist/cjs/theme/palette/colors/blue.js +1 -1
  229. package/dist/cjs/theme/palette/colors/common.js +1 -1
  230. package/dist/cjs/theme/palette/colors/green.js +1 -1
  231. package/dist/cjs/theme/palette/colors/grey.js +1 -1
  232. package/dist/cjs/theme/palette/colors/index.js +1 -1
  233. package/dist/cjs/theme/palette/colors/orange.js +1 -1
  234. package/dist/cjs/theme/palette/colors/purple.js +1 -1
  235. package/dist/cjs/theme/palette/colors/red.js +1 -1
  236. package/dist/cjs/theme/palette/colors/types.js +1 -1
  237. package/dist/cjs/theme/palette/error.js +1 -1
  238. package/dist/cjs/theme/palette/grey.js +1 -1
  239. package/dist/cjs/theme/palette/index.js +1 -1
  240. package/dist/cjs/theme/palette/palette-options.js +1 -1
  241. package/dist/cjs/theme/palette/primary.js +1 -1
  242. package/dist/cjs/theme/palette/secondary.js +1 -1
  243. package/dist/cjs/theme/palette/success.js +1 -1
  244. package/dist/cjs/theme/palette/text.js +1 -1
  245. package/dist/cjs/theme/palette/warning.js +1 -1
  246. package/dist/cjs/theme/theme.js +12 -1
  247. package/dist/cjs/theme/types/ThemeExtension.d.js +1 -1
  248. package/dist/cjs/theme/typography.js +1 -1
  249. package/dist/cjs/utils/combine-sx.js +1 -1
  250. package/dist/cjs/utils/component-ids.js +1 -1
  251. package/dist/cjs/utils/format.js +1 -1
  252. package/dist/cjs/utils/format.test.js +1 -1
  253. package/dist/cjs/utils/index.js +1 -1
  254. package/dist/cjs/utils/mathjs.js +1 -1
  255. package/dist/cjs/utils/theme-gen.js +6 -1
  256. package/dist/cjs/utils/theme-gen.test.js +6 -1
  257. package/dist/context/ChartsThemeProvider.js +1 -1
  258. package/dist/context/ChartsThemeProvider.js.map +1 -1
  259. package/dist/context/TimeZoneProvider.js +1 -1
  260. package/dist/context/TimeZoneProvider.js.map +1 -1
  261. package/dist/index.d.ts +2 -0
  262. package/dist/index.d.ts.map +1 -1
  263. package/dist/index.js +3 -1
  264. package/dist/index.js.map +1 -1
  265. package/dist/model/graph.d.ts +1 -16
  266. package/dist/model/graph.d.ts.map +1 -1
  267. package/dist/model/graph.js +1 -5
  268. package/dist/model/graph.js.map +1 -1
  269. package/dist/model/index.d.ts +1 -0
  270. package/dist/model/index.d.ts.map +1 -1
  271. package/dist/model/index.js +2 -1
  272. package/dist/model/index.js.map +1 -1
  273. package/dist/model/legend.d.ts +22 -0
  274. package/dist/model/legend.d.ts.map +1 -0
  275. package/dist/model/legend.js +51 -0
  276. package/dist/model/legend.js.map +1 -0
  277. package/dist/model/legend.test.d.ts +2 -0
  278. package/dist/model/legend.test.d.ts.map +1 -0
  279. package/dist/model/legend.test.js +27 -0
  280. package/dist/model/legend.test.js.map +1 -0
  281. package/dist/model/theme.d.ts +11 -0
  282. package/dist/model/theme.d.ts.map +1 -1
  283. package/dist/model/theme.js +1 -1
  284. package/dist/model/theme.js.map +1 -1
  285. package/dist/model/units/bytes.js +1 -1
  286. package/dist/model/units/bytes.js.map +1 -1
  287. package/dist/model/units/constants.js +1 -1
  288. package/dist/model/units/constants.js.map +1 -1
  289. package/dist/model/units/decimal.d.ts.map +1 -1
  290. package/dist/model/units/decimal.js +5 -2
  291. package/dist/model/units/decimal.js.map +1 -1
  292. package/dist/model/units/index.js +1 -1
  293. package/dist/model/units/index.js.map +1 -1
  294. package/dist/model/units/percent.js +1 -1
  295. package/dist/model/units/percent.js.map +1 -1
  296. package/dist/model/units/time.js +1 -1
  297. package/dist/model/units/time.js.map +1 -1
  298. package/dist/model/units/types.js +1 -1
  299. package/dist/model/units/types.js.map +1 -1
  300. package/dist/model/units/units.js +1 -1
  301. package/dist/model/units/units.js.map +1 -1
  302. package/dist/model/units/units.test.js +59 -6
  303. package/dist/model/units/units.test.js.map +1 -1
  304. package/dist/test/index.js +1 -1
  305. package/dist/test/index.js.map +1 -1
  306. package/dist/test/render.js +1 -1
  307. package/dist/test/render.js.map +1 -1
  308. package/dist/test/setup-tests.js +1 -1
  309. package/dist/test/setup-tests.js.map +1 -1
  310. package/dist/test-utils/index.js +1 -1
  311. package/dist/test-utils/index.js.map +1 -1
  312. package/dist/test-utils/theme.d.ts.map +1 -1
  313. package/dist/test-utils/theme.js +6 -1
  314. package/dist/test-utils/theme.js.map +1 -1
  315. package/dist/theme/index.js +1 -1
  316. package/dist/theme/index.js.map +1 -1
  317. package/dist/theme/palette/background.js +1 -1
  318. package/dist/theme/palette/background.js.map +1 -1
  319. package/dist/theme/palette/colors/blue.js +1 -1
  320. package/dist/theme/palette/colors/blue.js.map +1 -1
  321. package/dist/theme/palette/colors/common.js +1 -1
  322. package/dist/theme/palette/colors/common.js.map +1 -1
  323. package/dist/theme/palette/colors/green.js +1 -1
  324. package/dist/theme/palette/colors/green.js.map +1 -1
  325. package/dist/theme/palette/colors/grey.js +1 -1
  326. package/dist/theme/palette/colors/grey.js.map +1 -1
  327. package/dist/theme/palette/colors/index.js +1 -1
  328. package/dist/theme/palette/colors/index.js.map +1 -1
  329. package/dist/theme/palette/colors/orange.js +1 -1
  330. package/dist/theme/palette/colors/orange.js.map +1 -1
  331. package/dist/theme/palette/colors/purple.js +1 -1
  332. package/dist/theme/palette/colors/purple.js.map +1 -1
  333. package/dist/theme/palette/colors/red.js +1 -1
  334. package/dist/theme/palette/colors/red.js.map +1 -1
  335. package/dist/theme/palette/colors/types.js +1 -1
  336. package/dist/theme/palette/colors/types.js.map +1 -1
  337. package/dist/theme/palette/error.js +1 -1
  338. package/dist/theme/palette/error.js.map +1 -1
  339. package/dist/theme/palette/grey.js +1 -1
  340. package/dist/theme/palette/grey.js.map +1 -1
  341. package/dist/theme/palette/index.js +1 -1
  342. package/dist/theme/palette/index.js.map +1 -1
  343. package/dist/theme/palette/palette-options.js +1 -1
  344. package/dist/theme/palette/palette-options.js.map +1 -1
  345. package/dist/theme/palette/primary.js +1 -1
  346. package/dist/theme/palette/primary.js.map +1 -1
  347. package/dist/theme/palette/secondary.js +1 -1
  348. package/dist/theme/palette/secondary.js.map +1 -1
  349. package/dist/theme/palette/success.js +1 -1
  350. package/dist/theme/palette/success.js.map +1 -1
  351. package/dist/theme/palette/text.js +1 -1
  352. package/dist/theme/palette/text.js.map +1 -1
  353. package/dist/theme/palette/warning.js +1 -1
  354. package/dist/theme/palette/warning.js.map +1 -1
  355. package/dist/theme/theme.d.ts.map +1 -1
  356. package/dist/theme/theme.js +13 -2
  357. package/dist/theme/theme.js.map +1 -1
  358. package/dist/theme/types/ThemeExtension.d.js +1 -1
  359. package/dist/theme/types/ThemeExtension.d.js.map +1 -1
  360. package/dist/theme/typography.js +1 -1
  361. package/dist/theme/typography.js.map +1 -1
  362. package/dist/utils/combine-sx.js +1 -1
  363. package/dist/utils/combine-sx.js.map +1 -1
  364. package/dist/utils/component-ids.js +1 -1
  365. package/dist/utils/component-ids.js.map +1 -1
  366. package/dist/utils/format.js +1 -1
  367. package/dist/utils/format.js.map +1 -1
  368. package/dist/utils/format.test.js +1 -1
  369. package/dist/utils/format.test.js.map +1 -1
  370. package/dist/utils/index.js +1 -1
  371. package/dist/utils/index.js.map +1 -1
  372. package/dist/utils/mathjs.js +1 -1
  373. package/dist/utils/mathjs.js.map +1 -1
  374. package/dist/utils/theme-gen.d.ts.map +1 -1
  375. package/dist/utils/theme-gen.js +6 -1
  376. package/dist/utils/theme-gen.js.map +1 -1
  377. package/dist/utils/theme-gen.test.js +6 -1
  378. package/dist/utils/theme-gen.test.js.map +1 -1
  379. package/package.json +5 -3
  380. package/dist/Tooltip/SeriesInfo.d.ts.map +0 -1
  381. package/dist/Tooltip/SeriesInfo.js +0 -143
  382. package/dist/Tooltip/SeriesInfo.js.map +0 -1
  383. package/dist/Tooltip/SeriesMarker.d.ts.map +0 -1
  384. package/dist/Tooltip/SeriesMarker.js.map +0 -1
  385. package/dist/Tooltip/Tooltip.d.ts.map +0 -1
  386. package/dist/Tooltip/Tooltip.js.map +0 -1
  387. package/dist/Tooltip/TooltipContent.d.ts.map +0 -1
  388. package/dist/Tooltip/TooltipContent.js.map +0 -1
  389. package/dist/Tooltip/focused-series.d.ts.map +0 -1
  390. package/dist/Tooltip/focused-series.js.map +0 -1
  391. package/dist/Tooltip/focused-series.test.d.ts.map +0 -1
  392. package/dist/Tooltip/focused-series.test.js.map +0 -1
  393. package/dist/Tooltip/index.d.ts +0 -3
  394. package/dist/Tooltip/index.d.ts.map +0 -1
  395. package/dist/Tooltip/tooltip-model.d.ts.map +0 -1
  396. package/dist/Tooltip/tooltip-model.js.map +0 -1
  397. package/dist/Tooltip/utils.d.ts.map +0 -1
  398. package/dist/Tooltip/utils.js.map +0 -1
  399. package/dist/cjs/Tooltip/SeriesInfo.js +0 -149
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright 2022 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 { Drawer as MuiDrawer, DrawerProps as MuiDrawerProps } from '@mui/material';\nimport { combineSx } from '../utils';\n\nexport interface DrawerProps extends MuiDrawerProps {\n isOpen: boolean;\n onClose: () => void;\n anchor?: 'left' | 'right';\n}\n\nconst DRAWER_DEFAULT_WIDTH = 900;\n\nexport const Drawer = ({ anchor = 'right', isOpen, onClose, PaperProps, children, ...rest }: DrawerProps) => {\n return (\n <MuiDrawer\n {...rest}\n open={isOpen}\n onClose={onClose}\n anchor={anchor}\n PaperProps={{\n ...PaperProps,\n sx: combineSx(\n {\n width: `${DRAWER_DEFAULT_WIDTH}px`,\n overflow: 'hidden',\n },\n PaperProps?.sx\n ),\n }}\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","combineSx","DRAWER_DEFAULT_WIDTH","anchor","isOpen","onClose","PaperProps","children","rest","open","sx","width","overflow"],"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,MAAM,IAAIC,SAAS,QAAuC,eAAe,CAAC;AACnF,SAASC,SAAS,QAAQ,UAAU,CAAC;AAQrC,MAAMC,oBAAoB,GAAG,GAAG,AAAC;AAEjC,OAAO,MAAMH,MAAM,GAAG,CAAC,EAAEI,MAAM,EAAG,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGC,IAAI,EAAe,GAAK;IAC3G,qBACE,KAACR,SAAS;QACP,GAAGQ,IAAI;QACRC,IAAI,EAAEL,MAAM;QACZC,OAAO,EAAEA,OAAO;QAChBF,MAAM,EAAEA,MAAM;QACdG,UAAU,EAAE;YACV,GAAGA,UAAU;YACbI,EAAE,EAAET,SAAS,CACX;gBACEU,KAAK,EAAE,CAAC,EAAET,oBAAoB,CAAC,EAAE,CAAC;gBAClCU,QAAQ,EAAE,QAAQ;aACnB,EACDN,UAAU,aAAVA,UAAU,WAAI,GAAdA,KAAAA,CAAc,GAAdA,UAAU,CAAEI,EAAE,CACf;SACF;kBAEAH,QAAQ;MACC,CACZ;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/Drawer/Drawer.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 { Drawer as MuiDrawer, DrawerProps as MuiDrawerProps } from '@mui/material';\nimport { combineSx } from '../utils';\n\nexport interface DrawerProps extends MuiDrawerProps {\n isOpen: boolean;\n onClose: () => void;\n anchor?: 'left' | 'right';\n}\n\nconst DRAWER_DEFAULT_WIDTH = 900;\n\nexport const Drawer = ({ anchor = 'right', isOpen, onClose, PaperProps, children, ...rest }: DrawerProps) => {\n return (\n <MuiDrawer\n {...rest}\n open={isOpen}\n onClose={onClose}\n anchor={anchor}\n PaperProps={{\n ...PaperProps,\n sx: combineSx(\n {\n width: `${DRAWER_DEFAULT_WIDTH}px`,\n overflow: 'hidden',\n },\n PaperProps?.sx\n ),\n }}\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","combineSx","DRAWER_DEFAULT_WIDTH","anchor","isOpen","onClose","PaperProps","children","rest","open","sx","width","overflow"],"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,MAAM,IAAIC,SAAS,QAAuC,eAAe,CAAC;AACnF,SAASC,SAAS,QAAQ,UAAU,CAAC;AAQrC,MAAMC,oBAAoB,GAAG,GAAG,AAAC;AAEjC,OAAO,MAAMH,MAAM,GAAG,CAAC,EAAEI,MAAM,EAAG,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGC,IAAI,EAAe,GAAK;IAC3G,qBACE,KAACR,SAAS;QACP,GAAGQ,IAAI;QACRC,IAAI,EAAEL,MAAM;QACZC,OAAO,EAAEA,OAAO;QAChBF,MAAM,EAAEA,MAAM;QACdG,UAAU,EAAE;YACV,GAAGA,UAAU;YACbI,EAAE,EAAET,SAAS,CACX;gBACEU,KAAK,EAAE,CAAC,EAAET,oBAAoB,CAAC,EAAE,CAAC;gBAClCU,QAAQ,EAAE,QAAQ;aACnB,EACDN,UAAU,aAAVA,UAAU,WAAI,GAAdA,KAAAA,CAAc,GAAdA,UAAU,CAAEI,EAAE,CACf;SACF;kBAEAH,QAAQ;MACC,CACZ;AACJ,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Drawer/index.ts"],"sourcesContent":["// Copyright 2022 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 './Drawer';\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,UAAU,CAAC"}
1
+ {"version":3,"sources":["../../src/Drawer/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 './Drawer';\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,UAAU,CAAC"}
package/dist/EChart.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/EChart.tsx"],"sourcesContent":["// Copyright 2022 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, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport { isEqual, debounce } from 'lodash-es';\nimport { EChartsTheme } from './model';\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = typeof mouseEvents[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = typeof batchEvents[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = React.memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return () => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return () => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n useEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>) {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown) {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["React","useEffect","useLayoutEffect","useRef","init","Box","isEqual","debounce","mouseEvents","batchEvents","EChart","memo","option","theme","renderer","sx","onEvents","_instance","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"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,eAAe,EAAEC,MAAM,QAAQ,OAAO,CAAC;A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K,UAAU,EAAE;YACzC,IAAIC,YAAY,CAACF,SAAS,CAAC,EAAE;gBAC3BH,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,CAACI,MAAM,GAAKH,eAAe,CAACG,MAAM,EAAEP,QAAQ,CAAC,CAAC,CAAC;YACxE,OAAO,IAAIQ,YAAY,CAACL,SAAS,CAAC,EAAE;gBAClCH,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,CAACI,MAAM,GAAKH,eAAe,CAACG,MAAM,CAAC,CAAC,CAAC;YAC9D,OAAO;gBACLP,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,IAAMC,eAAe,CAAC,IAAI,EAAEJ,QAAQ,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAK,MAAMG,SAAS,IAAIF,MAAM,CAAE;QAC9B,IAAIQ,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,MAAM,EAAEE,SAAS,CAAC,EAAE;gBACvCF,UAA8B;YAAlD,MAAMY,WAAW,GAAGZ,CAAAA,UAA8B,GAA9BA,MAAM,CAACE,SAAS,CAAc,cAA9BF,UAA8B,cAA9BA,UAA8B,GAAI,IAAI,AAAC;YAC3D,IAAIY,WAAW,EAAE;gBACfX,SAAS,CAACC,SAAS,EAAeU,WAAW,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAASR,YAAY,CAACF,SAAoB,EAA+B;IACvE,OAAO,AAACjC,WAAW,CAAuB4C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC;AAED,SAASK,YAAY,CAACL,SAAoB,EAA+B;IACvE,OAAO,AAAChC,WAAW,CAAuB2C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC"}
1
+ {"version":3,"sources":["../src/EChart.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, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport { isEqual, debounce } from 'lodash-es';\nimport { EChartsTheme } from './model';\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = typeof mouseEvents[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = typeof batchEvents[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = React.memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return () => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return () => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n useEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>) {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown) {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["React","useEffect","useLayoutEffect","useRef","init","Box","isEqual","debounce","mouseEvents","batchEvents","EChart","memo","option","theme","renderer","sx","onEvents","_instance","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"mappings":"AAAA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AAChE,CAAC;AAED,SAASK,YAAY,CAACL,SAAoB,EAA+B;IACvE,OAAO,AAAChC,WAAW,CAAuB2C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ErrorAlert.tsx"],"sourcesContent":["// Copyright 2022 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 { Alert } from '@mui/material';\n\nexport interface ErrorAlertProps {\n error: Error;\n}\n\n/**\n * Shows an MUI Alert with the `Error.message` as its contents.\n */\nexport function ErrorAlert(props: ErrorAlertProps) {\n const { error } = props;\n return <Alert severity=\"error\">{error.message}</Alert>;\n}\n"],"names":["Alert","ErrorAlert","props","error","severity","message"],"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,KAAK,QAAQ,eAAe,CAAC;AAMtC;;CAEC,GACD,OAAO,SAASC,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGD,KAAK,AAAC;IACxB,qBAAO,KAACF,KAAK;QAACI,QAAQ,EAAC,OAAO;kBAAED,KAAK,CAACE,OAAO;MAAS,CAAC;AACzD,CAAC"}
1
+ {"version":3,"sources":["../src/ErrorAlert.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 { Alert } from '@mui/material';\n\nexport interface ErrorAlertProps {\n error: Error;\n}\n\n/**\n * Shows an MUI Alert with the `Error.message` as its contents.\n */\nexport function ErrorAlert(props: ErrorAlertProps) {\n const { error } = props;\n return <Alert severity=\"error\">{error.message}</Alert>;\n}\n"],"names":["Alert","ErrorAlert","props","error","severity","message"],"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,KAAK,QAAQ,eAAe,CAAC;AAMtC;;CAEC,GACD,OAAO,SAASC,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGD,KAAK,AAAC;IACxB,qBAAO,KAACF,KAAK;QAACI,QAAQ,EAAC,OAAO;kBAAED,KAAK,CAACE,OAAO;MAAS,CAAC;AACzD,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ErrorBoundary.ts"],"sourcesContent":["// Copyright 2022 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\n// Just use react-error-boundary as-is for now\nexport { ErrorBoundary } from 'react-error-boundary';\nexport type { ErrorBoundaryProps } from 'react-error-boundary';\n"],"names":["ErrorBoundary"],"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,8CAA8C;AAC9C,SAASA,aAAa,QAAQ,sBAAsB,CAAC"}
1
+ {"version":3,"sources":["../src/ErrorBoundary.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\n// Just use react-error-boundary as-is for now\nexport { ErrorBoundary } from 'react-error-boundary';\nexport type { ErrorBoundaryProps } from 'react-error-boundary';\n"],"names":["ErrorBoundary"],"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,8CAA8C;AAC9C,SAASA,aAAa,QAAQ,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU1D,oBAAY,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAExD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAkJhD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAWrG"}
1
+ {"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU1D,oBAAY,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAExD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAgJhD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAQrG"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -154,10 +154,7 @@ export function GaugeChart(props) {
154
154
  color: 'inherit',
155
155
  fontSize: valueSizeClamp,
156
156
  formatter: (value)=>{
157
- return formatValue(value, {
158
- kind: unit.kind,
159
- decimal_places: 0
160
- });
157
+ return formatValue(value, unit);
161
158
  }
162
159
  },
163
160
  data: [
@@ -194,7 +191,8 @@ export function GaugeChart(props) {
194
191
  return /*#__PURE__*/ _jsx(EChart, {
195
192
  sx: {
196
193
  width: width,
197
- height: height
194
+ height: height,
195
+ padding: `${chartsTheme.container.padding.default}px`
198
196
  },
199
197
  option: option,
200
198
  theme: chartsTheme.echartsTheme
@@ -207,10 +205,7 @@ export function GaugeChart(props) {
207
205
  const MIN_SIZE = 3;
208
206
  const MAX_SIZE = 24;
209
207
  const SIZE_MULTIPLIER = 0.7;
210
- const formattedValue = formatValue(value, {
211
- kind: unit.kind,
212
- decimal_places: 0
213
- });
208
+ const formattedValue = formatValue(value, unit);
214
209
  var _length;
215
210
  const valueCharacters = (_length = formattedValue.length) !== null && _length !== void 0 ? _length : 2;
216
211
  const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2022 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\ninterface 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, {\n kind: unit.kind,\n decimal_places: 0,\n });\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 }}\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, {\n kind: unit.kind,\n decimal_places: 0,\n });\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","kind","decimal_places","name","label","echartsTheme","textStyle","overflow","sx","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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AAC,CAAC;AAC/D,CAAC"}
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\ninterface 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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1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/GaugeChart/index.ts"],"sourcesContent":["// Copyright 2022 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 './GaugeChart';\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,cAAc,CAAC"}
1
+ {"version":3,"sources":["../../src/GaugeChart/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 './GaugeChart';\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,cAAc,CAAC"}
@@ -1,10 +1,5 @@
1
1
  import React from 'react';
2
- export declare enum TooltipPlacement {
3
- Top = "top",
4
- Left = "left",
5
- Right = "right",
6
- Bottom = "bottom"
7
- }
2
+ export declare type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom';
8
3
  interface InfoTooltipProps {
9
4
  description: string;
10
5
  children: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"InfoTooltip.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,oBAAY,gBAAgB;IAC1B,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,iFAQrB,gBAAgB,gBAalB,CAAC"}
1
+ {"version":3,"file":"InfoTooltip.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,oBAAY,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnE,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,iFAQrB,gBAAgB,gBAalB,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -13,18 +13,11 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import React from 'react';
15
15
  import { styled, Tooltip as MuiTooltip, tooltipClasses, Typography } from '@mui/material';
16
- export var TooltipPlacement;
17
- (function(TooltipPlacement) {
18
- TooltipPlacement["Top"] = 'top';
19
- TooltipPlacement["Left"] = 'left';
20
- TooltipPlacement["Right"] = 'right';
21
- TooltipPlacement["Bottom"] = 'bottom';
22
- })(TooltipPlacement || (TooltipPlacement = {}));
23
16
  export const InfoTooltip = ({ id , title , description , placement , children , enterDelay , enterNextDelay })=>{
24
17
  return /*#__PURE__*/ _jsx(StyledTooltip, {
25
18
  arrow: true,
26
19
  id: id,
27
- placement: placement !== null && placement !== void 0 ? placement : TooltipPlacement.Top,
20
+ placement: placement !== null && placement !== void 0 ? placement : 'top',
28
21
  title: /*#__PURE__*/ _jsx(TooltipContent, {
29
22
  title: title,
30
23
  description: description
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"sourcesContent":["// Copyright 2022 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 {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport enum TooltipPlacement {\n Top = 'top',\n Left = 'left',\n Right = 'right',\n Bottom = 'bottom',\n}\n\ninterface InfoTooltipProps {\n description: string;\n children: React.ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n enterDelay?: number; // default is 500ms\n enterNextDelay?: number; // default is 500ms\n}\n\nexport const InfoTooltip = ({\n id,\n title,\n description,\n placement,\n children,\n enterDelay,\n enterNextDelay,\n}: InfoTooltipProps) => {\n return (\n <StyledTooltip\n arrow\n id={id}\n placement={placement ?? TooltipPlacement.Top}\n title={<TooltipContent title={title} description={description} />}\n enterDelay={enterDelay ?? 500}\n enterNextDelay={enterNextDelay ?? 500}\n >\n <div>{children}</div>\n </StyledTooltip>\n );\n};\n\nconst TooltipContent = ({ title, description }: Pick<InfoTooltipProps, 'title' | 'description'>) => {\n return (\n <>\n {title && (\n <Typography\n variant=\"body2\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightMedium,\n })}\n >\n {title}\n </Typography>\n )}\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n })}\n >\n {description}\n </Typography>\n </>\n );\n};\n\nconst StyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (\n <MuiTooltip {...props} classes={{ popper: className }} />\n))(({ theme }) => ({\n [`& .${tooltipClasses.tooltip}`]: {\n backgroundColor: theme.palette.background.tooltip,\n color: theme.palette.text.primary,\n maxWidth: '300px',\n padding: theme.spacing(1),\n boxShadow: theme.shadows[1],\n },\n [`& .${tooltipClasses.arrow}`]: {\n color: theme.palette.background.tooltip,\n },\n}));\n"],"names":["React","styled","Tooltip","MuiTooltip","tooltipClasses","Typography","TooltipPlacement","Top","Left","Right","Bottom","InfoTooltip","id","title","description","placement","children","enterDelay","enterNextDelay","StyledTooltip","arrow","TooltipContent","div","variant","sx","theme","color","palette","text","primary","fontWeight","typography","fontWeightMedium","className","props","classes","popper","tooltip","backgroundColor","background","maxWidth","padding","spacing","boxShadow","shadows"],"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,SACEC,MAAM,EAENC,OAAO,IAAIC,UAAU,EACrBC,cAAc,EACdC,UAAU,QACL,eAAe,CAAC;WAEhB,gBAKN;UALWC,gBAAgB;IAAhBA,gBAAgB,CAC1BC,KAAG,IAAG,KAAK;IADDD,gBAAgB,CAE1BE,MAAI,IAAG,MAAM;IAFHF,gBAAgB,CAG1BG,OAAK,IAAG,OAAO;IAHLH,gBAAgB,CAI1BI,QAAM,IAAG,QAAQ;GAJPJ,gBAAgB,KAAhBA,gBAAgB;AAiB5B,OAAO,MAAMK,WAAW,GAAG,CAAC,EAC1BC,EAAE,CAAA,EACFC,KAAK,CAAA,EACLC,WAAW,CAAA,EACXC,SAAS,CAAA,EACTC,QAAQ,CAAA,EACRC,UAAU,CAAA,EACVC,cAAc,CAAA,EACG,GAAK;IACtB,qBACE,KAACC,aAAa;QACZC,KAAK;QACLR,EAAE,EAAEA,EAAE;QACNG,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAIT,gBAAgB,CAACC,GAAG;QAC5CM,KAAK,gBAAE,KAACQ,cAAc;YAACR,KAAK,EAAEA,KAAK;YAAEC,WAAW,EAAEA,WAAW;UAAI;QACjEG,UAAU,EAAEA,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,GAAG;QAC7BC,cAAc,EAAEA,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAI,GAAG;kBAErC,cAAA,KAACI,KAA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QACD,CAAC,CAAC,GAAG,EAAExC,cAAc,CAACgB,KAAK,CAAC,CAAC,CAAC,EAAE;YAC9BM,KAAK,EAAED,KAAK,CAACE,OAAO,CAACY,UAAU,CAACF,OAAO;SACxC;KACF,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.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 {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom';\n\ninterface InfoTooltipProps {\n description: string;\n children: React.ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n enterDelay?: number; // default is 500ms\n enterNextDelay?: number; // default is 500ms\n}\n\nexport const InfoTooltip = ({\n id,\n title,\n description,\n placement,\n children,\n enterDelay,\n enterNextDelay,\n}: InfoTooltipProps) => {\n return (\n <StyledTooltip\n arrow\n id={id}\n placement={placement ?? 'top'}\n title={<TooltipContent title={title} description={description} />}\n enterDelay={enterDelay ?? 500}\n enterNextDelay={enterNextDelay ?? 500}\n >\n <div>{children}</div>\n </StyledTooltip>\n );\n};\n\nconst TooltipContent = ({ title, description }: Pick<InfoTooltipProps, 'title' | 'description'>) => {\n return (\n <>\n {title && (\n <Typography\n variant=\"body2\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightMedium,\n })}\n >\n {title}\n </Typography>\n )}\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n })}\n >\n {description}\n </Typography>\n </>\n );\n};\n\nconst StyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (\n <MuiTooltip {...props} classes={{ popper: className }} />\n))(({ theme }) => ({\n [`& .${tooltipClasses.tooltip}`]: {\n backgroundColor: theme.palette.background.tooltip,\n color: theme.palette.text.primary,\n maxWidth: '300px',\n padding: theme.spacing(1),\n boxShadow: theme.shadows[1],\n },\n [`& .${tooltipClasses.arrow}`]: {\n color: theme.palette.background.tooltip,\n },\n}));\n"],"names":["React","styled","Tooltip","MuiTooltip","tooltipClasses","Typography","InfoTooltip","id","title","description","placement","children","enterDelay","enterNextDelay","StyledTooltip","arrow","TooltipContent","div","variant","sx","theme","color","palette","text","primary","fontWeight","typography","fontWeightMedium","className","props","classes","popper","tooltip","backgroundColor","background","maxWidth","padding","spacing","boxShadow","shadows"],"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,SACEC,MAAM,EAENC,OAAO,IAAIC,UAAU,EACrBC,cAAc,EACdC,UAAU,QACL,eAAe,CAAC;AAcvB,OAAO,MAAMC,WAAW,GAAG,CAAC,EAC1BC,EAAE,CAAA,EACFC,KAAK,CAAA,EACLC,WAAW,CAAA,EACXC,SAAS,CAAA,EACTC,QAAQ,CAAA,EACRC,UAAU,CAAA,EACVC,cAAc,CAAA,EACG,GAAK;IACtB,qBACE,KAACC,aAAa;QACZC,KAAK;QACLR,EAAE,EAAEA,EAAE;QACNG,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,KAAK;QAC7BF,KAAK,gBAAE,KAACQ,cAAc;YAACR,KAAK,EAAEA,KAAK;YAAEC,W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O,CAACC,IAAI,CAACC,OAAO;YACjCW,QAAQ,EAAE,OAAO;YACjBC,OAAO,EAAEhB,KAAK,CAACiB,OAAO,CAAC,CAAC,CAAC;YACzBC,SAAS,EAAElB,KAAK,CAACmB,OAAO,CAAC,CAAC,CAAC;SAC5B;QACD,CAAC,CAAC,GAAG,EAAEnC,cAAc,CAACW,KAAK,CAAC,CAAC,CAAC,EAAE;YAC9BM,KAAK,EAAED,KAAK,CAACE,OAAO,CAACY,UAAU,CAACF,OAAO;SACxC;KACF,CAAA,AAAC,CAAC,AAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.test.tsx"],"sourcesContent":["// Copyright 2022 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 { render } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/dom';\nimport { InfoTooltip } from './InfoTooltip';\n\ndescribe('InfoTooltip', () => {\n const title = 'Tooltip Title';\n const description = 'this is a tooltip';\n it('should render title and description', async () => {\n render(\n <InfoTooltip title={title} description={description}>\n <div>tooltipAnchor</div>\n </InfoTooltip>\n );\n const tooltipAnchor = screen.getByText('tooltipAnchor');\n userEvent.hover(tooltipAnchor);\n await screen.findByText(title);\n screen.findByText(description);\n });\n});\n"],"names":["render","userEvent","screen","InfoTooltip","describe","title","description","it","div","tooltipAnchor","getByText","hover","findByText"],"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,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,MAAM,QAAQ,sBAAsB,CAAC;AAC9C,SAASC,WAAW,QAAQ,eAAe,CAAC;AAE5CC,QAAQ,CAAC,aAAa,EAAE,IAAM;IAC5B,MAAMC,KAAK,GAAG,eAAe,AAAC;IAC9B,MAAMC,WAAW,GAAG,mBAAmB,AAAC;IACxCC,EAAE,CAAC,qCAAqC,EAAE,UAAY;QACpDP,MAAM,eACJ,KAACG,WAAW;YAACE,KAAK,EAAEA,KAAK;YAAEC,WAAW,EAAEA,WAAW;sBACjD,cAAA,KAACE,KAAG;0BAAC,eAAa;cAAM;UACZ,CACf,CAAC;QACF,MAAMC,aAAa,GAAGP,MAAM,CAACQ,SAAS,CAAC,eAAe,CAAC,AAAC;QACxDT,SAAS,CAACU,KAAK,CAACF,aAAa,CAAC,CAAC;QAC/B,MAAMP,MAAM,CAACU,UAAU,CAACP,KAAK,CAAC,CAAC;QAC/BH,MAAM,CAACU,UAAU,CAACN,WAAW,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.test.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 { render } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/dom';\nimport { InfoTooltip } from './InfoTooltip';\n\ndescribe('InfoTooltip', () => {\n const title = 'Tooltip Title';\n const description = 'this is a tooltip';\n it('should render title and description', async () => {\n render(\n <InfoTooltip title={title} description={description}>\n <div>tooltipAnchor</div>\n </InfoTooltip>\n );\n const tooltipAnchor = screen.getByText('tooltipAnchor');\n userEvent.hover(tooltipAnchor);\n await screen.findByText(title);\n screen.findByText(description);\n });\n});\n"],"names":["render","userEvent","screen","InfoTooltip","describe","title","description","it","div","tooltipAnchor","getByText","hover","findByText"],"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,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,MAAM,QAAQ,sBAAsB,CAAC;AAC9C,SAASC,WAAW,QAAQ,eAAe,CAAC;AAE5CC,QAAQ,CAAC,aAAa,EAAE,IAAM;IAC5B,MAAMC,KAAK,GAAG,eAAe,AAAC;IAC9B,MAAMC,WAAW,GAAG,mBAAmB,AAAC;IACxCC,EAAE,CAAC,qCAAqC,EAAE,UAAY;QACpDP,MAAM,eACJ,KAACG,WAAW;YAACE,KAAK,EAAEA,KAAK;YAAEC,WAAW,EAAEA,WAAW;sBACjD,cAAA,KAACE,KAAG;0BAAC,eAAa;cAAM;UACZ,CACf,CAAC;QACF,MAAMC,aAAa,GAAGP,MAAM,CAACQ,SAAS,CAAC,eAAe,CAAC,AAAC;QACxDT,SAAS,CAACU,KAAK,CAACF,aAAa,CAAC,CAAC;QAC/B,MAAMP,MAAM,CAACU,UAAU,CAACP,KAAK,CAAC,CAAC;QAC/BH,MAAM,CAACU,UAAU,CAACN,WAAW,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/InfoTooltip/index.ts"],"sourcesContent":["// Copyright 2022 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 './InfoTooltip';\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,eAAe,CAAC"}
1
+ {"version":3,"sources":["../../src/InfoTooltip/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 './InfoTooltip';\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,eAAe,CAAC"}
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
- interface JSONEditorProps<Spec> {
3
- value: Spec;
4
- onChange?: (next: Spec) => void;
5
- }
2
+ import { ReactCodeMirrorProps } from '@uiw/react-codemirror/src';
3
+ declare type JSONEditorProps<T> = Omit<ReactCodeMirrorProps, 'onBlur' | 'theme' | 'extensions' | 'onChange' | 'value'> & {
4
+ value: T;
5
+ onChange?: (next: T) => void;
6
+ };
6
7
  export declare function JSONEditor<T>(props: JSONEditorProps<T>): JSX.Element;
7
8
  export {};
8
9
  //# sourceMappingURL=JSONEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"JSONEditor.d.ts","sourceRoot":"","sources":["../src/JSONEditor.tsx"],"names":[],"mappings":";AAgBA,UAAU,eAAe,CAAC,IAAI;IAC5B,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,eAmCtD"}
1
+ {"version":3,"file":"JSONEditor.d.ts","sourceRoot":"","sources":["../src/JSONEditor.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,aAAK,eAAe,CAAC,CAAC,IAAI,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,CAAC,GAAG;IAC/G,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAC9B,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,eAgCtD"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -12,37 +12,42 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { useEffect, useState } from 'react';
15
- import { TextField } from '@mui/material';
15
+ import CodeMirror from '@uiw/react-codemirror';
16
+ import { json, jsonParseLinter } from '@codemirror/lang-json';
17
+ import { linter, lintGutter } from '@codemirror/lint';
18
+ import { useTheme } from '@mui/material';
16
19
  export function JSONEditor(props) {
20
+ const theme = useTheme();
21
+ const isDarkMode = theme.palette.mode === 'dark';
17
22
  const [value, setValue] = useState(()=>JSON.stringify(props.value, null, 2));
18
- const [invalidJSON, setInvalidJSON] = useState(false);
19
23
  useEffect(()=>{
20
24
  setValue(JSON.stringify(props.value, null, 2));
21
- setInvalidJSON(false);
22
25
  }, [
23
26
  props.value
24
27
  ]);
25
- // TODO: replace with CodeMirror editor
26
- return /*#__PURE__*/ _jsx(TextField, {
27
- label: "JSON",
28
- error: invalidJSON,
29
- helperText: invalidJSON ? 'Invalid JSON' : '',
30
- multiline: true,
31
- fullWidth: true,
28
+ return /*#__PURE__*/ _jsx(CodeMirror, {
29
+ ...props,
30
+ style: {
31
+ border: `1px solid ${theme.palette.divider}`
32
+ },
33
+ theme: isDarkMode ? 'dark' : 'light',
34
+ extensions: [
35
+ json(),
36
+ linter(jsonParseLinter()),
37
+ lintGutter()
38
+ ],
32
39
  value: value,
33
- onChange: (event)=>{
34
- setValue(event.target.value);
40
+ onChange: (newValue)=>{
41
+ setValue(newValue);
35
42
  },
36
- maxRows: 20,
37
43
  onBlur: ()=>{
38
44
  try {
39
45
  const json = JSON.parse(value !== null && value !== void 0 ? value : '{}');
40
- setInvalidJSON(false);
41
46
  if (props.onChange !== undefined) {
42
47
  props.onChange(json);
43
48
  }
44
49
  } catch (e) {
45
- setInvalidJSON(true);
50
+ // ignore this error
46
51
  }
47
52
  }
48
53
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/JSONEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { useEffect, useState } from 'react';\nimport { TextField } from '@mui/material';\n\ninterface JSONEditorProps<Spec> {\n value: Spec;\n onChange?: (next: Spec) => void;\n}\n\nexport function JSONEditor<T>(props: JSONEditorProps<T>) {\n const [value, setValue] = useState(() => JSON.stringify(props.value, null, 2));\n const [invalidJSON, setInvalidJSON] = useState(false);\n\n useEffect(() => {\n setValue(JSON.stringify(props.value, null, 2));\n setInvalidJSON(false);\n }, [props.value]);\n\n // TODO: replace with CodeMirror editor\n return (\n <TextField\n label=\"JSON\"\n error={invalidJSON}\n helperText={invalidJSON ? 'Invalid JSON' : ''}\n multiline\n fullWidth\n value={value}\n onChange={(event) => {\n setValue(event.target.value);\n }}\n maxRows={20}\n onBlur={() => {\n try {\n const json = JSON.parse(value ?? '{}');\n setInvalidJSON(false);\n if (props.onChange !== undefined) {\n props.onChange(json);\n }\n } catch (e) {\n setInvalidJSON(true);\n }\n }}\n />\n );\n}\n"],"names":["useEffect","useState","TextField","JSONEditor","props","value","setValue","JSON","stringify","invalidJSON","setInvalidJSON","label","error","helperText","multiline","fullWidth","onChange","event","target","maxRows","onBlur","json","parse","undefined","e"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,m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CAAC,KAAK,CAAC,CAAC;gBACtB,IAAIN,KAAK,CAACY,QAAQ,KAAKO,SAAS,EAAE;oBAChCnB,KAAK,CAACY,QAAQ,CAACK,IAAI,CAAC,CAAC;gBACvB,CAAC;YACH,EAAE,OAAOG,CAAC,EAAE;gBACVd,cAAc,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;MACD,CACF;AACJ,CAAC"}
1
+ {"version":3,"sources":["../src/JSONEditor.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 { useEffect, useState } from 'react';\nimport CodeMirror from '@uiw/react-codemirror';\nimport { json, jsonParseLinter } from '@codemirror/lang-json';\nimport { linter, lintGutter } from '@codemirror/lint';\nimport { useTheme } from '@mui/material';\nimport { ReactCodeMirrorProps } from '@uiw/react-codemirror/src';\n\ntype JSONEditorProps<T> = Omit<ReactCodeMirrorProps, 'onBlur' | 'theme' | 'extensions' | 'onChange' | 'value'> & {\n value: T;\n onChange?: (next: T) => void;\n};\n\nexport function JSONEditor<T>(props: JSONEditorProps<T>) {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const [value, setValue] = useState(() => JSON.stringify(props.value, null, 2));\n\n useEffect(() => {\n setValue(JSON.stringify(props.value, null, 2));\n }, [props.value]);\n\n return (\n <CodeMirror\n {...props}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n extensions={[json(), linter(jsonParseLinter()), lintGutter()]}\n value={value}\n onChange={(newValue) => {\n setValue(newValue);\n }}\n onBlur={() => {\n try {\n const json = JSON.parse(value ?? '{}');\n if (props.onChange !== undefined) {\n props.onChange(json);\n }\n } catch (e) {\n // ignore this error\n }\n }}\n />\n );\n}\n"],"names":["useEffect","useState","CodeMirror","json","jsonParseLinter","linter","lintGutter","useTheme","JSONEditor","props","theme","isDarkMode","palette","mode","value","setValue","JSON","stringify","style","border","divider","extensions","onChange","newValue","onBlur","parse","undefined","e"],"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,SAAS,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC5C,OAAOC,UAAU,MAAM,uBAAuB,CAAC;AAC/C,SAASC,IAAI,EAAEC,eAAe,QAAQ,uBAAuB,CAAC;AAC9D,SAASC,MAAM,EAAEC,UAAU,QAAQ,kBAAkB,CAAC;AACtD,SAASC,QAAQ,QAAQ,eAAe,CAAC;AAQzC,OAAO,SAASC,UAAU,CAAIC,KAAyB,EAAE;IACvD,MAAMC,KAAK,GAAGH,QAAQ,EAAE,AAAC;IACzB,MAAMI,UAAU,GAAGD,KAAK,CAACE,OAAO,CAACC,IAAI,KAAK,MAAM,AAAC;IAEjD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGd,QAAQ,CAAC,IAAMe,IAAI,CAACC,SAAS,CAACR,KAAK,CAACK,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,AAAC;IAE/Ed,SAAS,CAAC,IAAM;QACde,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACR,KAAK,CAACK,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC,EAAE;QAACL,KAAK,CAACK,KAAK;KAAC,CAAC,CAAC;IAElB,qBACE,KAACZ,UAAU;QACR,GAAGO,KAAK;QACTS,KAAK,EAAE;YAAEC,MAAM,EAAE,CAAC,UAAU,EAAET,KAAK,CAACE,OAAO,CAACQ,OAAO,CAAC,CAAC;SAAE;QACvDV,KAAK,EAAEC,UAAU,GAAG,MAAM,GAAG,OAAO;QACpCU,UAAU,EAAE;YAAClB,IAAI,EAAE;YAAEE,MAAM,CAACD,eAAe,EAAE,CAAC;YAAEE,UAAU,EAAE;SAAC;QAC7DQ,KAAK,EAAEA,KAAK;QACZQ,QAAQ,EAAE,CAACC,QAAQ,GAAK;YACtBR,QAAQ,CAACQ,QAAQ,CAAC,CAAC;QACrB,CAAC;QACDC,MAAM,EAAE,IAAM;YACZ,IAAI;gBACF,MAAMrB,IAAI,GAAGa,IAAI,CAACS,KAAK,CAACX,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,IAAI,CAAC,AAAC;gBACvC,IAAIL,KAAK,CAACa,QAAQ,KAAKI,SAAS,EAAE;oBAChCjB,KAAK,CAACa,QAAQ,CAACnB,IAAI,CAAC,CAAC;gBACvB,CAAC;YACH,EAAE,OAAOwB,CAAC,EAAE;YACV,oBAAoB;YACtB,CAAC;QACH,CAAC;MACD,CACF;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/CompactLegend.tsx"],"sourcesContent":["// Copyright 2022 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 } from '../model';\nimport { ListLegendItem } from './ListLegendItem';\n\ninterface CompactLegendProps {\n height: number;\n items: LegendItem[];\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`\n */\nexport function CompactLegend({ height, items }: 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 sx={{\n width: 'auto',\n float: 'left',\n paddingRight: 1.5,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ListLegendItem","CompactLegend","height","items","component","sx","width","padding","overflowY","margin","map","item","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;AAEpC,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAOlD;;;CAGC,GACD,OAAO,SAASC,aAAa,CAAC,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAsB,EAAE;IACnE,qBACE,KAACJ,GAAG;QAACK,SAAS,EAAC,IAAI;QAACC,EAAE,EAAE;YAAEC,KAAK,EAAE,MAAM;YAAEJ,MAAM;YAAEK,OAAO,EAAE;AAAC,iBAAC;AAAE,iBAAC;AAAE,iBAAC;AAAE,iBAAC;aAAC;YAAEC,SAAS,EAAE,QAAQ;YAAEC,MAAM,EAAE,CAAC;SAAE;kBACrGN,KAAK,CAACO,GAAG,CAAC,CAACC,IAAI,iBACd,KAACX,cAAc;gBAEbW,IAAI,EAAEA,IAAI;gBACVN,EAAE,EAAE;oBACFC,KAAK,EAAE,MAAM;oBACbM,KAAK,EAAE,MAAM;oBACbC,YAAY,EAAE,GAAG;iBAClB;eANIF,IAAI,CAACG,EAAE,CAOZ,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 { LegendItem } from '../model';\nimport { ListLegendItem } from './ListLegendItem';\n\ninterface CompactLegendProps {\n height: number;\n items: LegendItem[];\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`\n */\nexport function CompactLegend({ height, items }: 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 sx={{\n width: 'auto',\n float: 'left',\n paddingRight: 1.5,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ListLegendItem","CompactLegend","height","items","component","sx","width","padding","overflowY","margin","map","item","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;AAEpC,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAOlD;;;CAGC,GACD,OAAO,SAASC,aAAa,CAAC,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAsB,EAAE;IACnE,qBACE,KAACJ,GAAG;QAACK,SAAS,EAAC,IAAI;QAACC,EAAE,EAAE;YAAEC,KAAK,EAAE,MAAM;YAAEJ,MAAM;YAAEK,OAAO,EAAE;AAAC,iBAAC;AAAE,iBAAC;AAAE,iBAAC;AAAE,iBAAC;aAAC;YAAEC,SAAS,EAAE,QAAQ;YAAEC,MAAM,EAAE,CAAC;SAAE;kBACrGN,KAAK,CAACO,GAAG,CAAC,CAACC,IAAI,iBACd,KAACX,cAAc;gBAEbW,IAAI,EAAEA,IAAI;gBACVN,EAAE,EAAE;oBACFC,KAAK,EAAE,MAAM;oBACbM,KAAK,EAAE,MAAM;oBACbC,YAAY,EAAE,GAAG;iBAClB;eANIF,IAAI,CAACG,EAAE,CAOZ,AACH,CAAC;MACE,CACN;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIrD,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,WAAW,eAmBnE"}
1
+ {"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIrD,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,WAAW,eA+BnE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -10,12 +10,12 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ListLegend } from './ListLegend';
16
16
  import { CompactLegend } from './CompactLegend';
17
17
  export function Legend({ width , height , options , data }) {
18
- if (options.position === 'right') {
18
+ if (options.position === 'Right') {
19
19
  return /*#__PURE__*/ _jsx(Box, {
20
20
  sx: {
21
21
  width: width,
@@ -23,6 +23,7 @@ export function Legend({ width , height , options , data }) {
23
23
  position: 'absolute',
24
24
  top: 0,
25
25
  right: 0,
26
+ overflowX: 'hidden',
26
27
  overflowY: 'scroll'
27
28
  },
28
29
  children: /*#__PURE__*/ _jsx(ListLegend, {
@@ -30,9 +31,20 @@ export function Legend({ width , height , options , data }) {
30
31
  })
31
32
  });
32
33
  }
33
- return /*#__PURE__*/ _jsx(CompactLegend, {
34
- items: data,
35
- height: height
34
+ return /*#__PURE__*/ _jsxs(Box, {
35
+ sx: {
36
+ width: width,
37
+ height: height,
38
+ position: 'absolute',
39
+ bottom: 0
40
+ },
41
+ children: [
42
+ /*#__PURE__*/ _jsx(CompactLegend, {
43
+ items: data,
44
+ height: height
45
+ }),
46
+ ";"
47
+ ]
36
48
  });
37
49
  }
38
50
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/Legend.tsx"],"sourcesContent":["// Copyright 2022 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 { LegendOptions, LegendItem } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\n\ninterface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendOptions;\n}\n\nexport function Legend({ width, height, options, data }: LegendProps) {\n if (options.position === 'right') {\n return (\n <Box\n sx={{\n width: width,\n height: '100%',\n position: 'absolute',\n top: 0,\n right: 0,\n overflowY: 'scroll',\n }}\n >\n <ListLegend items={data} />\n </Box>\n );\n }\n\n return <CompactLegend items={data} height={height} />;\n}\n"],"names":["Box","ListLegend","CompactLegend","Legend","width","height","options","data","position","sx","top","right","overflowY","items"],"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;AAEpC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAShD,OAAO,SAASC,MAAM,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,IAAI,CAAA,EAAe,EAAE;IACpE,IAAID,OAAO,CAACE,QAAQ,KAAK,OAAO,EAAE;QAChC,qBACE,KAACR,GAAG;YACFS,EAAE,EAAE;gBACFL,KAAK,EAAEA,KAAK;gBACZC,MAAM,EAAE,MAAM;gBACdG,QAAQ,EAAE,UAAU;gBACpBE,GAAG,EAAE,CAAC;gBACNC,KAAK,EAAE,CAAC;gBACRC,SAAS,EAAE,QAAQ;aACpB;sBAED,cAAA,KAACX,UAAU;gBAACY,KAAK,EAAEN,IAAI;cAAI;UACvB,CACN;IACJ,CAAC;IAED,qBAAO,KAACL,aAAa;QAACW,KAAK,EAAEN,IAAI;QAAEF,MAAM,EAAEA,MAAM;MAAI,CAAC;AACxD,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 { LegendOptions, LegendItem } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\n\ninterface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendOptions;\n}\n\nexport function Legend({ width, height, options, data }: LegendProps) {\n if (options.position === 'Right') {\n return (\n <Box\n sx={{\n width: width,\n height: '100%',\n position: 'absolute',\n top: 0,\n right: 0,\n overflowX: 'hidden',\n overflowY: 'scroll',\n }}\n >\n <ListLegend items={data} />\n </Box>\n );\n }\n\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n bottom: 0,\n }}\n >\n <CompactLegend items={data} height={height} />;\n </Box>\n );\n}\n"],"names":["Box","ListLegend","CompactLegend","Legend","width","height","options","data","position","sx","top","right","overflowX","overflowY","items","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;AAEpC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAShD,OAAO,SAASC,MAAM,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,IAAI,CAAA,EAAe,EAAE;IACpE,IAAID,OAAO,CAACE,QAAQ,KAAK,OAAO,EAAE;QAChC,qBACE,KAACR,GAAG;YACFS,EAAE,EAAE;gBACFL,KAAK,EAAEA,KAAK;gBACZC,MAAM,EAAE,MAAM;gBACdG,QAAQ,EAAE,UAAU;gBACpBE,GAAG,EAAE,CAAC;gBACNC,KAAK,EAAE,CAAC;gBACRC,SAAS,EAAE,QAAQ;gBACnBC,SAAS,EAAE,QAAQ;aACpB;sBAED,cAAA,KAACZ,UAAU;gBAACa,KAAK,EAAEP,IAAI;cAAI;UACvB,CACN;IACJ,CAAC;IAED,qBACE,MAACP,GAAG;QACFS,EAAE,EAAE;YACFL,KAAK,EAAEA,KAAK;YACZC,MAAM,EAAEA,MAAM;YACdG,QAAQ,EAAE,UAAU;YACpBO,MAAM,EAAE,CAAC;SACV;;0BAED,KAACb,aAAa;gBAACY,KAAK,EAAEP,IAAI;gBAAEF,MAAM,EAAEA,MAAM;cAAI;YAAA,GAChD;;MAAM,CACN;AACJ,CAAC"}