@perses-dev/components 0.21.1 → 0.22.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 (379) hide show
  1. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js +1 -1
  2. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -1
  3. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +1 -1
  4. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  5. package/dist/DateTimeRangePicker/TimeRangeSelector.js +1 -1
  6. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  7. package/dist/DateTimeRangePicker/index.js +1 -1
  8. package/dist/DateTimeRangePicker/index.js.map +1 -1
  9. package/dist/DateTimeRangePicker/utils.js +1 -1
  10. package/dist/DateTimeRangePicker/utils.js.map +1 -1
  11. package/dist/Drawer/Drawer.js +1 -1
  12. package/dist/Drawer/Drawer.js.map +1 -1
  13. package/dist/Drawer/index.js +1 -1
  14. package/dist/Drawer/index.js.map +1 -1
  15. package/dist/EChart.js +1 -1
  16. package/dist/EChart.js.map +1 -1
  17. package/dist/ErrorAlert.js +1 -1
  18. package/dist/ErrorAlert.js.map +1 -1
  19. package/dist/ErrorBoundary.js +1 -1
  20. package/dist/ErrorBoundary.js.map +1 -1
  21. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  22. package/dist/GaugeChart/GaugeChart.js +3 -9
  23. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  24. package/dist/GaugeChart/index.js +1 -1
  25. package/dist/GaugeChart/index.js.map +1 -1
  26. package/dist/InfoTooltip/InfoTooltip.d.ts +1 -6
  27. package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -1
  28. package/dist/InfoTooltip/InfoTooltip.js +2 -9
  29. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  30. package/dist/InfoTooltip/InfoTooltip.test.js +1 -1
  31. package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -1
  32. package/dist/InfoTooltip/index.js +1 -1
  33. package/dist/InfoTooltip/index.js.map +1 -1
  34. package/dist/JSONEditor.d.ts +5 -4
  35. package/dist/JSONEditor.d.ts.map +1 -1
  36. package/dist/JSONEditor.js +21 -16
  37. package/dist/JSONEditor.js.map +1 -1
  38. package/dist/Legend/CompactLegend.js +1 -1
  39. package/dist/Legend/CompactLegend.js.map +1 -1
  40. package/dist/Legend/Legend.d.ts.map +1 -1
  41. package/dist/Legend/Legend.js +18 -6
  42. package/dist/Legend/Legend.js.map +1 -1
  43. package/dist/Legend/LegendColorBadge.js +1 -1
  44. package/dist/Legend/LegendColorBadge.js.map +1 -1
  45. package/dist/Legend/ListLegend.js +1 -1
  46. package/dist/Legend/ListLegend.js.map +1 -1
  47. package/dist/Legend/ListLegendItem.js +1 -1
  48. package/dist/Legend/ListLegendItem.js.map +1 -1
  49. package/dist/Legend/index.js +1 -1
  50. package/dist/Legend/index.js.map +1 -1
  51. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  52. package/dist/LegendOptionsEditor/LegendOptionsEditor.js +13 -18
  53. package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  54. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js +23 -2
  55. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js.map +1 -1
  56. package/dist/LegendOptionsEditor/index.js +1 -1
  57. package/dist/LegendOptionsEditor/index.js.map +1 -1
  58. package/dist/LineChart/LineChart.js +3 -3
  59. package/dist/LineChart/LineChart.js.map +1 -1
  60. package/dist/LineChart/index.js +1 -1
  61. package/dist/LineChart/index.js.map +1 -1
  62. package/dist/LineChart/utils.js +1 -1
  63. package/dist/LineChart/utils.js.map +1 -1
  64. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
  65. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  66. package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  67. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  68. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
  69. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  70. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
  71. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  72. package/dist/OptionsEditorLayout/index.js +1 -1
  73. package/dist/OptionsEditorLayout/index.js.map +1 -1
  74. package/dist/StatChart/StatChart.js +1 -1
  75. package/dist/StatChart/StatChart.js.map +1 -1
  76. package/dist/StatChart/StatChart.test.js +1 -1
  77. package/dist/StatChart/StatChart.test.js.map +1 -1
  78. package/dist/StatChart/index.js +1 -1
  79. package/dist/StatChart/index.js.map +1 -1
  80. package/dist/{Tooltip → TimeSeriesTooltip}/SeriesInfo.d.ts +1 -2
  81. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -0
  82. package/dist/TimeSeriesTooltip/SeriesInfo.js +89 -0
  83. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -0
  84. package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts +2 -0
  85. package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts.map +1 -0
  86. package/dist/TimeSeriesTooltip/SeriesInfo.test.js +52 -0
  87. package/dist/TimeSeriesTooltip/SeriesInfo.test.js.map +1 -0
  88. package/dist/TimeSeriesTooltip/SeriesLabelsStack.d.ts +9 -0
  89. package/dist/TimeSeriesTooltip/SeriesLabelsStack.d.ts.map +1 -0
  90. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +99 -0
  91. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -0
  92. package/dist/{Tooltip → TimeSeriesTooltip}/SeriesMarker.d.ts +2 -1
  93. package/dist/TimeSeriesTooltip/SeriesMarker.d.ts.map +1 -0
  94. package/dist/{Tooltip → TimeSeriesTooltip}/SeriesMarker.js +7 -7
  95. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -0
  96. package/dist/{Tooltip/Tooltip.d.ts → TimeSeriesTooltip/TimeSeriesTooltip.d.ts} +4 -4
  97. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -0
  98. package/dist/{Tooltip/Tooltip.js → TimeSeriesTooltip/TimeSeriesTooltip.js} +3 -4
  99. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -0
  100. package/dist/{Tooltip → TimeSeriesTooltip}/TooltipContent.d.ts +1 -2
  101. package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -0
  102. package/dist/{Tooltip → TimeSeriesTooltip}/TooltipContent.js +1 -1
  103. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -0
  104. package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts +2 -0
  105. package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts.map +1 -0
  106. package/dist/TimeSeriesTooltip/TooltipContent.test.js +78 -0
  107. package/dist/TimeSeriesTooltip/TooltipContent.test.js.map +1 -0
  108. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.d.ts +0 -0
  109. package/dist/TimeSeriesTooltip/focused-series.d.ts.map +1 -0
  110. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.js +3 -3
  111. package/dist/TimeSeriesTooltip/focused-series.js.map +1 -0
  112. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.test.d.ts +0 -0
  113. package/dist/TimeSeriesTooltip/focused-series.test.d.ts.map +1 -0
  114. package/dist/{Tooltip → TimeSeriesTooltip}/focused-series.test.js +1 -1
  115. package/dist/TimeSeriesTooltip/focused-series.test.js.map +1 -0
  116. package/dist/TimeSeriesTooltip/index.d.ts +9 -0
  117. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -0
  118. package/dist/{Tooltip → TimeSeriesTooltip}/index.js +8 -2
  119. package/dist/TimeSeriesTooltip/index.js.map +1 -0
  120. package/dist/{Tooltip → TimeSeriesTooltip}/tooltip-model.d.ts +0 -0
  121. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -0
  122. package/dist/{Tooltip → TimeSeriesTooltip}/tooltip-model.js +1 -1
  123. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -0
  124. package/dist/{Tooltip → TimeSeriesTooltip}/utils.d.ts +0 -0
  125. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -0
  126. package/dist/{Tooltip → TimeSeriesTooltip}/utils.js +1 -1
  127. package/dist/TimeSeriesTooltip/utils.js.map +1 -0
  128. package/dist/UnitSelector/UnitSelector.js +1 -1
  129. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  130. package/dist/UnitSelector/UnitSelector.test.js +1 -1
  131. package/dist/UnitSelector/UnitSelector.test.js.map +1 -1
  132. package/dist/UnitSelector/index.js +1 -1
  133. package/dist/UnitSelector/index.js.map +1 -1
  134. package/dist/YAxisLabel.js +1 -1
  135. package/dist/YAxisLabel.js.map +1 -1
  136. package/dist/cjs/DateTimeRangePicker/AbsoluteTimePicker.js +1 -1
  137. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +1 -1
  138. package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +1 -1
  139. package/dist/cjs/DateTimeRangePicker/index.js +1 -1
  140. package/dist/cjs/DateTimeRangePicker/utils.js +1 -1
  141. package/dist/cjs/Drawer/Drawer.js +1 -1
  142. package/dist/cjs/Drawer/index.js +1 -1
  143. package/dist/cjs/EChart.js +1 -1
  144. package/dist/cjs/ErrorAlert.js +1 -1
  145. package/dist/cjs/ErrorBoundary.js +1 -1
  146. package/dist/cjs/GaugeChart/GaugeChart.js +3 -9
  147. package/dist/cjs/GaugeChart/index.js +1 -1
  148. package/dist/cjs/InfoTooltip/InfoTooltip.js +5 -18
  149. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +1 -1
  150. package/dist/cjs/InfoTooltip/index.js +1 -1
  151. package/dist/cjs/JSONEditor.js +25 -15
  152. package/dist/cjs/Legend/CompactLegend.js +1 -1
  153. package/dist/cjs/Legend/Legend.js +17 -5
  154. package/dist/cjs/Legend/LegendColorBadge.js +1 -1
  155. package/dist/cjs/Legend/ListLegend.js +1 -1
  156. package/dist/cjs/Legend/ListLegendItem.js +1 -1
  157. package/dist/cjs/Legend/index.js +1 -1
  158. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +13 -18
  159. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.test.js +23 -2
  160. package/dist/cjs/LegendOptionsEditor/index.js +1 -1
  161. package/dist/cjs/LineChart/LineChart.js +3 -3
  162. package/dist/cjs/LineChart/index.js +1 -1
  163. package/dist/cjs/LineChart/utils.js +1 -1
  164. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
  165. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  166. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
  167. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
  168. package/dist/cjs/OptionsEditorLayout/index.js +1 -1
  169. package/dist/cjs/StatChart/StatChart.js +1 -1
  170. package/dist/cjs/StatChart/StatChart.test.js +1 -1
  171. package/dist/cjs/StatChart/index.js +1 -1
  172. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +95 -0
  173. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.test.js +54 -0
  174. package/dist/cjs/TimeSeriesTooltip/SeriesLabelsStack.js +105 -0
  175. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/SeriesMarker.js +7 -7
  176. package/dist/cjs/{Tooltip/Tooltip.js → TimeSeriesTooltip/TimeSeriesTooltip.js} +4 -4
  177. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/TooltipContent.js +1 -1
  178. package/dist/cjs/TimeSeriesTooltip/TooltipContent.test.js +80 -0
  179. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/focused-series.js +3 -3
  180. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/focused-series.test.js +1 -1
  181. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/index.js +8 -2
  182. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/tooltip-model.js +1 -1
  183. package/dist/cjs/{Tooltip → TimeSeriesTooltip}/utils.js +1 -1
  184. package/dist/cjs/UnitSelector/UnitSelector.js +1 -1
  185. package/dist/cjs/UnitSelector/UnitSelector.test.js +1 -1
  186. package/dist/cjs/UnitSelector/index.js +1 -1
  187. package/dist/cjs/YAxisLabel.js +1 -1
  188. package/dist/cjs/context/ChartsThemeProvider.js +1 -1
  189. package/dist/cjs/context/TimeZoneProvider.js +1 -1
  190. package/dist/cjs/index.js +2 -1
  191. package/dist/cjs/model/graph.js +4 -15
  192. package/dist/cjs/model/index.js +2 -1
  193. package/dist/cjs/model/legend.js +67 -0
  194. package/dist/cjs/model/legend.test.js +29 -0
  195. package/dist/cjs/model/theme.js +1 -1
  196. package/dist/cjs/model/units/bytes.js +1 -1
  197. package/dist/cjs/model/units/constants.js +1 -1
  198. package/dist/cjs/model/units/decimal.js +1 -1
  199. package/dist/cjs/model/units/index.js +1 -1
  200. package/dist/cjs/model/units/percent.js +1 -1
  201. package/dist/cjs/model/units/time.js +1 -1
  202. package/dist/cjs/model/units/types.js +1 -1
  203. package/dist/cjs/model/units/units.js +1 -1
  204. package/dist/cjs/model/units/units.test.js +5 -6
  205. package/dist/cjs/test/index.js +1 -1
  206. package/dist/cjs/test/render.js +1 -1
  207. package/dist/cjs/test/setup-tests.js +1 -1
  208. package/dist/cjs/test-utils/index.js +1 -1
  209. package/dist/cjs/test-utils/theme.js +1 -1
  210. package/dist/cjs/theme/index.js +1 -1
  211. package/dist/cjs/theme/palette/background.js +1 -1
  212. package/dist/cjs/theme/palette/colors/blue.js +1 -1
  213. package/dist/cjs/theme/palette/colors/common.js +1 -1
  214. package/dist/cjs/theme/palette/colors/green.js +1 -1
  215. package/dist/cjs/theme/palette/colors/grey.js +1 -1
  216. package/dist/cjs/theme/palette/colors/index.js +1 -1
  217. package/dist/cjs/theme/palette/colors/orange.js +1 -1
  218. package/dist/cjs/theme/palette/colors/purple.js +1 -1
  219. package/dist/cjs/theme/palette/colors/red.js +1 -1
  220. package/dist/cjs/theme/palette/colors/types.js +1 -1
  221. package/dist/cjs/theme/palette/error.js +1 -1
  222. package/dist/cjs/theme/palette/grey.js +1 -1
  223. package/dist/cjs/theme/palette/index.js +1 -1
  224. package/dist/cjs/theme/palette/palette-options.js +1 -1
  225. package/dist/cjs/theme/palette/primary.js +1 -1
  226. package/dist/cjs/theme/palette/secondary.js +1 -1
  227. package/dist/cjs/theme/palette/success.js +1 -1
  228. package/dist/cjs/theme/palette/text.js +1 -1
  229. package/dist/cjs/theme/palette/warning.js +1 -1
  230. package/dist/cjs/theme/theme.js +12 -1
  231. package/dist/cjs/theme/types/ThemeExtension.d.js +1 -1
  232. package/dist/cjs/theme/typography.js +1 -1
  233. package/dist/cjs/utils/combine-sx.js +1 -1
  234. package/dist/cjs/utils/component-ids.js +1 -1
  235. package/dist/cjs/utils/format.js +1 -1
  236. package/dist/cjs/utils/format.test.js +1 -1
  237. package/dist/cjs/utils/index.js +1 -1
  238. package/dist/cjs/utils/mathjs.js +1 -1
  239. package/dist/cjs/utils/theme-gen.js +1 -1
  240. package/dist/cjs/utils/theme-gen.test.js +1 -1
  241. package/dist/context/ChartsThemeProvider.js +1 -1
  242. package/dist/context/ChartsThemeProvider.js.map +1 -1
  243. package/dist/context/TimeZoneProvider.js +1 -1
  244. package/dist/context/TimeZoneProvider.js.map +1 -1
  245. package/dist/index.d.ts +1 -0
  246. package/dist/index.d.ts.map +1 -1
  247. package/dist/index.js +2 -1
  248. package/dist/index.js.map +1 -1
  249. package/dist/model/graph.d.ts +1 -16
  250. package/dist/model/graph.d.ts.map +1 -1
  251. package/dist/model/graph.js +1 -5
  252. package/dist/model/graph.js.map +1 -1
  253. package/dist/model/index.d.ts +1 -0
  254. package/dist/model/index.d.ts.map +1 -1
  255. package/dist/model/index.js +2 -1
  256. package/dist/model/index.js.map +1 -1
  257. package/dist/model/legend.d.ts +22 -0
  258. package/dist/model/legend.d.ts.map +1 -0
  259. package/dist/model/legend.js +51 -0
  260. package/dist/model/legend.js.map +1 -0
  261. package/dist/model/legend.test.d.ts +2 -0
  262. package/dist/model/legend.test.d.ts.map +1 -0
  263. package/dist/model/legend.test.js +27 -0
  264. package/dist/model/legend.test.js.map +1 -0
  265. package/dist/model/theme.js +1 -1
  266. package/dist/model/theme.js.map +1 -1
  267. package/dist/model/units/bytes.js +1 -1
  268. package/dist/model/units/bytes.js.map +1 -1
  269. package/dist/model/units/constants.js +1 -1
  270. package/dist/model/units/constants.js.map +1 -1
  271. package/dist/model/units/decimal.js +1 -1
  272. package/dist/model/units/decimal.js.map +1 -1
  273. package/dist/model/units/index.js +1 -1
  274. package/dist/model/units/index.js.map +1 -1
  275. package/dist/model/units/percent.js +1 -1
  276. package/dist/model/units/percent.js.map +1 -1
  277. package/dist/model/units/time.js +1 -1
  278. package/dist/model/units/time.js.map +1 -1
  279. package/dist/model/units/types.js +1 -1
  280. package/dist/model/units/types.js.map +1 -1
  281. package/dist/model/units/units.js +1 -1
  282. package/dist/model/units/units.js.map +1 -1
  283. package/dist/model/units/units.test.js +5 -6
  284. package/dist/model/units/units.test.js.map +1 -1
  285. package/dist/test/index.js +1 -1
  286. package/dist/test/index.js.map +1 -1
  287. package/dist/test/render.js +1 -1
  288. package/dist/test/render.js.map +1 -1
  289. package/dist/test/setup-tests.js +1 -1
  290. package/dist/test/setup-tests.js.map +1 -1
  291. package/dist/test-utils/index.js +1 -1
  292. package/dist/test-utils/index.js.map +1 -1
  293. package/dist/test-utils/theme.js +1 -1
  294. package/dist/test-utils/theme.js.map +1 -1
  295. package/dist/theme/index.js +1 -1
  296. package/dist/theme/index.js.map +1 -1
  297. package/dist/theme/palette/background.js +1 -1
  298. package/dist/theme/palette/background.js.map +1 -1
  299. package/dist/theme/palette/colors/blue.js +1 -1
  300. package/dist/theme/palette/colors/blue.js.map +1 -1
  301. package/dist/theme/palette/colors/common.js +1 -1
  302. package/dist/theme/palette/colors/common.js.map +1 -1
  303. package/dist/theme/palette/colors/green.js +1 -1
  304. package/dist/theme/palette/colors/green.js.map +1 -1
  305. package/dist/theme/palette/colors/grey.js +1 -1
  306. package/dist/theme/palette/colors/grey.js.map +1 -1
  307. package/dist/theme/palette/colors/index.js +1 -1
  308. package/dist/theme/palette/colors/index.js.map +1 -1
  309. package/dist/theme/palette/colors/orange.js +1 -1
  310. package/dist/theme/palette/colors/orange.js.map +1 -1
  311. package/dist/theme/palette/colors/purple.js +1 -1
  312. package/dist/theme/palette/colors/purple.js.map +1 -1
  313. package/dist/theme/palette/colors/red.js +1 -1
  314. package/dist/theme/palette/colors/red.js.map +1 -1
  315. package/dist/theme/palette/colors/types.js +1 -1
  316. package/dist/theme/palette/colors/types.js.map +1 -1
  317. package/dist/theme/palette/error.js +1 -1
  318. package/dist/theme/palette/error.js.map +1 -1
  319. package/dist/theme/palette/grey.js +1 -1
  320. package/dist/theme/palette/grey.js.map +1 -1
  321. package/dist/theme/palette/index.js +1 -1
  322. package/dist/theme/palette/index.js.map +1 -1
  323. package/dist/theme/palette/palette-options.js +1 -1
  324. package/dist/theme/palette/palette-options.js.map +1 -1
  325. package/dist/theme/palette/primary.js +1 -1
  326. package/dist/theme/palette/primary.js.map +1 -1
  327. package/dist/theme/palette/secondary.js +1 -1
  328. package/dist/theme/palette/secondary.js.map +1 -1
  329. package/dist/theme/palette/success.js +1 -1
  330. package/dist/theme/palette/success.js.map +1 -1
  331. package/dist/theme/palette/text.js +1 -1
  332. package/dist/theme/palette/text.js.map +1 -1
  333. package/dist/theme/palette/warning.js +1 -1
  334. package/dist/theme/palette/warning.js.map +1 -1
  335. package/dist/theme/theme.d.ts.map +1 -1
  336. package/dist/theme/theme.js +13 -2
  337. package/dist/theme/theme.js.map +1 -1
  338. package/dist/theme/types/ThemeExtension.d.js +1 -1
  339. package/dist/theme/types/ThemeExtension.d.js.map +1 -1
  340. package/dist/theme/typography.js +1 -1
  341. package/dist/theme/typography.js.map +1 -1
  342. package/dist/utils/combine-sx.js +1 -1
  343. package/dist/utils/combine-sx.js.map +1 -1
  344. package/dist/utils/component-ids.js +1 -1
  345. package/dist/utils/component-ids.js.map +1 -1
  346. package/dist/utils/format.js +1 -1
  347. package/dist/utils/format.js.map +1 -1
  348. package/dist/utils/format.test.js +1 -1
  349. package/dist/utils/format.test.js.map +1 -1
  350. package/dist/utils/index.js +1 -1
  351. package/dist/utils/index.js.map +1 -1
  352. package/dist/utils/mathjs.js +1 -1
  353. package/dist/utils/mathjs.js.map +1 -1
  354. package/dist/utils/theme-gen.js +1 -1
  355. package/dist/utils/theme-gen.js.map +1 -1
  356. package/dist/utils/theme-gen.test.js +1 -1
  357. package/dist/utils/theme-gen.test.js.map +1 -1
  358. package/package.json +4 -2
  359. package/dist/Tooltip/SeriesInfo.d.ts.map +0 -1
  360. package/dist/Tooltip/SeriesInfo.js +0 -143
  361. package/dist/Tooltip/SeriesInfo.js.map +0 -1
  362. package/dist/Tooltip/SeriesMarker.d.ts.map +0 -1
  363. package/dist/Tooltip/SeriesMarker.js.map +0 -1
  364. package/dist/Tooltip/Tooltip.d.ts.map +0 -1
  365. package/dist/Tooltip/Tooltip.js.map +0 -1
  366. package/dist/Tooltip/TooltipContent.d.ts.map +0 -1
  367. package/dist/Tooltip/TooltipContent.js.map +0 -1
  368. package/dist/Tooltip/focused-series.d.ts.map +0 -1
  369. package/dist/Tooltip/focused-series.js.map +0 -1
  370. package/dist/Tooltip/focused-series.test.d.ts.map +0 -1
  371. package/dist/Tooltip/focused-series.test.js.map +0 -1
  372. package/dist/Tooltip/index.d.ts +0 -3
  373. package/dist/Tooltip/index.d.ts.map +0 -1
  374. package/dist/Tooltip/index.js.map +0 -1
  375. package/dist/Tooltip/tooltip-model.d.ts.map +0 -1
  376. package/dist/Tooltip/tooltip-model.js.map +0 -1
  377. package/dist/Tooltip/utils.d.ts.map +0 -1
  378. package/dist/Tooltip/utils.js.map +0 -1
  379. package/dist/cjs/Tooltip/SeriesInfo.js +0 -149
@@ -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,18 +12,18 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
+ import { combineSx } from '../utils';
15
16
  export function SeriesMarker(props) {
16
- const { markerColor } = props;
17
+ const { markerColor , sx } = props;
17
18
  return /*#__PURE__*/ _jsx(Box, {
18
- sx: {
19
+ sx: combineSx({
19
20
  display: 'inline-block',
20
- width: '12px',
21
+ width: '11px',
22
+ height: '11px',
21
23
  borderRadius: '2px',
22
- height: '12px',
23
- marginTop: 0.25,
24
24
  marginRight: 1,
25
25
  verticalAlign: 'top'
26
- },
26
+ }, sx),
27
27
  style: {
28
28
  backgroundColor: markerColor
29
29
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesMarker.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, BoxProps } from '@mui/material';\nimport { combineSx } from '../utils';\n\ninterface SeriesMarkerProps extends BoxProps<'div'> {\n markerColor: string;\n}\n\nexport function SeriesMarker(props: SeriesMarkerProps) {\n const { markerColor, sx } = props;\n return (\n <Box\n sx={combineSx(\n {\n display: 'inline-block',\n width: '11px',\n height: '11px',\n borderRadius: '2px',\n marginRight: 1,\n verticalAlign: 'top',\n },\n sx\n )}\n style={{ backgroundColor: markerColor }}\n ></Box>\n );\n}\n"],"names":["Box","combineSx","SeriesMarker","props","markerColor","sx","display","width","height","borderRadius","marginRight","verticalAlign","style","backgroundColor"],"mappings":"AAAA,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,QAAkB,eAAe,CAAC;AAC9C,SAASC,SAAS,QAAQ,UAAU,CAAC;AAMrC,OAAO,SAASC,YAAY,CAACC,KAAwB,EAAE;IACrD,MAAM,EAAEC,WAAW,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGF,KAAK,AAAC;IAClC,qBACE,KAACH,GAAG;QACFK,EAAE,EAAEJ,SAAS,CACX;YACEK,OAAO,EAAE,cAAc;YACvBC,KAAK,EAAE,MAAM;YACbC,MAAM,EAAE,MAAM;YACdC,YAAY,EAAE,KAAK;YACnBC,WAAW,EAAE,CAAC;YACdC,aAAa,EAAE,KAAK;SACrB,EACDN,EAAE,CACH;QACDO,KAAK,EAAE;YAAEC,eAAe,EAAET,WAAW;SAAE;MAClC,CACP;AACJ,CAAC"}
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import { ECharts as EChartsInstance } from 'echarts/core';
3
3
  import { EChartsDataFormat, UnitOptions } from '../model';
4
- interface TooltipProps {
4
+ interface TimeSeriesTooltipProps {
5
5
  chartRef: React.MutableRefObject<EChartsInstance | undefined>;
6
6
  chartData: EChartsDataFormat;
7
7
  pinTooltip: boolean;
8
8
  wrapLabels?: boolean;
9
9
  unit?: UnitOptions;
10
10
  }
11
- declare const Tooltip: React.NamedExoticComponent<TooltipProps>;
12
- export { Tooltip };
13
- //# sourceMappingURL=Tooltip.d.ts.map
11
+ export declare const TimeSeriesTooltip: React.NamedExoticComponent<TimeSeriesTooltipProps>;
12
+ export {};
13
+ //# sourceMappingURL=TimeSeriesTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeSeriesTooltip.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TimeSeriesTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAM1D,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,eAAO,MAAM,iBAAiB,oDA2D5B,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
@@ -17,7 +17,7 @@ import { getFocusedSeriesData } from './focused-series';
17
17
  import { TOOLTIP_MAX_HEIGHT, TOOLTIP_MAX_WIDTH, useMousePosition } from './tooltip-model';
18
18
  import { TooltipContent } from './TooltipContent';
19
19
  import { assembleTransform } from './utils';
20
- const Tooltip = /*#__PURE__*/ React.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip , unit }) {
20
+ export const TimeSeriesTooltip = /*#__PURE__*/ React.memo(function TimeSeriesTooltip({ chartRef , chartData , wrapLabels , pinTooltip , unit }) {
21
21
  const [pinnedPos, setPinnedPos] = useState(null);
22
22
  const mousePos = useMousePosition();
23
23
  if (mousePos === null || mousePos.target === null) return null;
@@ -67,6 +67,5 @@ const Tooltip = /*#__PURE__*/ React.memo(function Tooltip({ chartRef , chartData
67
67
  })
68
68
  });
69
69
  });
70
- export { Tooltip };
71
70
 
72
- //# sourceMappingURL=Tooltip.js.map
71
+ //# sourceMappingURL=TimeSeriesTooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TimeSeriesTooltip.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, { useState } from 'react';\nimport { Box, Portal } from '@mui/material';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { EChartsDataFormat, UnitOptions } from '../model';\nimport { getFocusedSeriesData } from './focused-series';\nimport { CursorCoordinates, TOOLTIP_MAX_HEIGHT, TOOLTIP_MAX_WIDTH, useMousePosition } from './tooltip-model';\nimport { TooltipContent } from './TooltipContent';\nimport { assembleTransform } from './utils';\n\ninterface TimeSeriesTooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n chartData: EChartsDataFormat;\n pinTooltip: boolean;\n wrapLabels?: boolean;\n unit?: UnitOptions;\n}\n\nexport const TimeSeriesTooltip = React.memo(function TimeSeriesTooltip({\n chartRef,\n chartData,\n wrapLabels,\n pinTooltip,\n unit,\n}: TimeSeriesTooltipProps) {\n const [pinnedPos, setPinnedPos] = useState<CursorCoordinates | null>(null);\n const mousePos = useMousePosition();\n\n if (mousePos === null || mousePos.target === null) return null;\n\n // ensure user is hovering over a chart before checking for nearby series\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const focusedSeries = getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit);\n const chartWidth = chart?.getWidth() ?? 750;\n const chartHeight = chart?.getHeight() ?? 230;\n const cursorTransform = assembleTransform(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);\n\n if (focusedSeries.length === 0) {\n return null;\n }\n\n if (pinTooltip === true && pinnedPos === null) {\n setPinnedPos(mousePos);\n }\n\n return (\n <Portal>\n <Box\n sx={(theme) => ({\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: TOOLTIP_MAX_HEIGHT,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: '#2E313E', // TODO: use colors from theme, separate styles for dark mode\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n zIndex: theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n })}\n style={{\n transform: cursorTransform,\n }}\n >\n <TooltipContent focusedSeries={focusedSeries} wrapLabels={wrapLabels} />\n </Box>\n </Portal>\n );\n});\n"],"names":["React","useState","Box","Portal","getFocusedSeriesData","TOOLTIP_MAX_HEIGHT","TOOLTIP_MAX_WIDTH","useMousePosition","TooltipContent","assembleTransform","TimeSeriesTooltip","memo","chartRef","chartData","wrapLabels","pinTooltip","unit","pinnedPos","setPinnedPos","mousePos","target","tagName","chart","current","focusedSeries","chartWidth","getWidth","chartHeight","getHeight","cursorTransform","length","sx","theme","maxWidth","maxHeight","position","top","left","backgroundColor","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY","style","transform"],"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,QAAQ,QAAQ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+1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { FocusedSeriesArray } from './focused-series';
3
- interface TooltipContentProps {
3
+ export interface TooltipContentProps {
4
4
  focusedSeries: FocusedSeriesArray | null;
5
5
  wrapLabels?: boolean;
6
6
  }
7
7
  export declare function TooltipContent(props: TooltipContentProps): JSX.Element;
8
- export {};
9
8
  //# sourceMappingURL=TooltipContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAqExD"}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.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 { useMemo } from 'react';\nimport { Box, Divider, Stack, Typography } from '@mui/material';\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport { FocusedSeriesArray } from './focused-series';\nimport { SeriesInfo } from './SeriesInfo';\n\nexport interface TooltipContentProps {\n focusedSeries: FocusedSeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { focusedSeries, wrapLabels } = props;\n const { formatWithUserTimeZone } = useTimeZone();\n\n const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;\n\n const formatTimeSeriesHeader = (timeString: string) => {\n const date = new Date(timeString);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n\n return (\n <>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </>\n );\n };\n\n const sortedFocusedSeries = useMemo(() => {\n if (focusedSeries === null) return null;\n return focusedSeries.sort((a, b) => (a.y > b.y ? -1 : 1));\n }, [focusedSeries]);\n\n if (sortedFocusedSeries !== null && seriesTime !== null) {\n return (\n <Stack py={1} px={1.5} spacing={0.5}>\n <Typography variant=\"caption\">{formatTimeSeriesHeader(seriesTime)}</Typography>\n <Divider\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n })}\n />\n <Box\n sx={{\n display: 'table',\n }}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n />\n );\n })}\n </Box>\n </Stack>\n );\n } else {\n return <></>;\n }\n}\n"],"names":["useMemo","Box","Divider","Stack","Typography","useTimeZone","SeriesInfo","TooltipContent","props","focusedSeries","wrapLabels","formatWithUserTimeZone","seriesTime","date","formatTimeSeriesHeader","timeString","Date","formattedDate","formattedTime","variant","sx","theme","color","palette","common","white","strong","sortedFocusedSeries","sort","a","b","y","py","px","spacing","borderColor","grey","display","map","datumIdx","seriesIdx","seriesName","formattedY","markerColor","key","toString","totalSeries","length"],"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,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAChE,SAASC,WAAW,QAAQ,6BAA6B,CAAC;AAE1D,SAASC,UAAU,QAAQ,cAAc,CAAC;AAO1C,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,aAAa,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAC5C,MAAM,EAAEG,sBAAsB,CAAA,EAAE,GAAGN,WAAW,EAAE,AAAC;IAEjD,MAAMO,UAAU,GAAGH,aAAa,IAAIA,aAAa,CAAC,CAAC,CAAC,IAAIA,aAAa,CAAC,CAAC,CAAC,CAACI,IAAI,GAAGJ,aAAa,CAAC,CAAC,CAAC,CAACI,IAAI,GAAG,IAAI,AAAC;IAE7G,MAAMC,sBAAsB,GAAG,CAACC,UAAkB,GAAK;QACrD,MAAMF,IAAI,GAAG,IAAIG,IAAI,CAACD,UAAU,CAAC,AAAC;QAClC,MAAME,aAAa,GAAGN,sBAAsB,CAACE,IAAI,EAAE,iBAAiB,CAAC,AAAC;QACtE,MAAMK,aAAa,GAAGP,sBAAsB,CAACE,IAAI,EAAE,UAAU,CAAC,AAAC;QAE/D,qBACE;;8BACE,KAACT,UAAU;oBACTe,OAAO,EAAC,SAAS;oBACjBC,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4BACdC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AI,IAAIC,SAAS,KAAK,IAAI,EAAE,OAAO,IAAI,CAAC;wBACzD,MAAMI,GAAG,GAAGJ,SAAS,CAACK,QAAQ,EAAE,GAAGN,QAAQ,CAACM,QAAQ,EAAE,AAAC;wBAEvD,qBACE,KAACvC,UAAU;4BAETmC,UAAU,EAAEA,UAAU;4BACtBV,CAAC,EAAEA,CAAC;4BACJW,UAAU,EAAEA,UAAU;4BACtBC,WAAW,EAAEA,WAAW;4BACxBG,WAAW,EAAEnB,mBAAmB,CAACoB,MAAM;4BACvCrC,UAAU,EAAEA,UAAU;2BANjBkC,GAAG,CAOR,CACF;oBACJ,CAAC,CAAC;kBACE;;UACA,CACR;IACJ,OAAO;QACL,qBAAO,mBAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TooltipContent.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TooltipContent.test.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TooltipContent.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { render } from '@testing-library/react';
15
+ import { screen } from '@testing-library/dom';
16
+ import { TooltipContent } from './TooltipContent';
17
+ describe('TooltipContent', ()=>{
18
+ const renderComponent = (props)=>{
19
+ render(/*#__PURE__*/ _jsx(TooltipContent, {
20
+ ...props
21
+ }));
22
+ };
23
+ it('render tooltip content with a single series name', ()=>{
24
+ const tooltipContent = {
25
+ focusedSeries: [
26
+ {
27
+ seriesIdx: 0,
28
+ datumIdx: 84,
29
+ seriesName: 'Test node demo.do.prometheus.io:9100',
30
+ date: 'Dec 23, 2022, 1:53:00 PM',
31
+ x: 1671821580000,
32
+ y: 0.1,
33
+ formattedY: '0.1',
34
+ markerColor: 'hsla(19838016,50%,50%,0.8)'
35
+ }
36
+ ],
37
+ wrapLabels: true
38
+ };
39
+ renderComponent(tooltipContent);
40
+ expect(screen.getByText('Test node demo.do.prometheus.io:9100')).toBeInTheDocument();
41
+ expect(screen.getByText('Dec 23, 2022 -')).toBeInTheDocument();
42
+ expect(screen.getByText('13:53:00')).toBeInTheDocument();
43
+ expect(screen.getByText('0.1')).toBeInTheDocument();
44
+ });
45
+ it('render tooltip content with multiple series data', ()=>{
46
+ const tooltipContent = {
47
+ focusedSeries: [
48
+ {
49
+ seriesIdx: 2,
50
+ datumIdx: 48,
51
+ seriesName: 'node_memory_MemFree_bytes{env="demo",instance="demo.do.prometheus.io:9100",job="node"}',
52
+ date: 'Dec 23, 2022, 1:44:00 PM',
53
+ x: 1671821040000,
54
+ y: 84635648,
55
+ formattedY: '84.64M',
56
+ markerColor: 'hsla(1887856572,50%,50%,0.8)'
57
+ },
58
+ {
59
+ seriesIdx: 1,
60
+ datumIdx: 48,
61
+ seriesName: 'node_memory_Buffers_bytes{env="demo",instance="demo.do.prometheus.io:9100",job="node"}',
62
+ date: 'Dec 23, 2022, 1:44:00 PM',
63
+ x: 1671821040000,
64
+ y: 33771520,
65
+ formattedY: '33.77M',
66
+ markerColor: 'hsla(158479636,50%,50%,0.8)'
67
+ }
68
+ ],
69
+ wrapLabels: true
70
+ };
71
+ renderComponent(tooltipContent);
72
+ expect(screen.getByText('84.64M')).toBeInTheDocument();
73
+ expect(screen.getByText('33.77M')).toBeInTheDocument();
74
+ expect(screen.getAllByText('env="demo", instance="demo.do.prometheus.io:9100", job="node"')).toHaveLength(2);
75
+ });
76
+ });
77
+
78
+ //# sourceMappingURL=TooltipContent.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.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 { screen } from '@testing-library/dom';\nimport { TooltipContent, TooltipContentProps } from './TooltipContent';\n\ndescribe('TooltipContent', () => {\n const renderComponent = (props: TooltipContentProps) => {\n render(<TooltipContent {...props} />);\n };\n\n it('render tooltip content with a single series name', () => {\n const tooltipContent: TooltipContentProps = {\n focusedSeries: [\n {\n seriesIdx: 0,\n datumIdx: 84,\n seriesName: 'Test node demo.do.prometheus.io:9100',\n date: 'Dec 23, 2022, 1:53:00 PM',\n x: 1671821580000,\n y: 0.1,\n formattedY: '0.1',\n markerColor: 'hsla(19838016,50%,50%,0.8)',\n },\n ],\n wrapLabels: true,\n };\n renderComponent(tooltipContent);\n expect(screen.getByText('Test node demo.do.prometheus.io:9100')).toBeInTheDocument();\n expect(screen.getByText('Dec 23, 2022 -')).toBeInTheDocument();\n expect(screen.getByText('13:53:00')).toBeInTheDocument();\n expect(screen.getByText('0.1')).toBeInTheDocument();\n });\n\n it('render tooltip content with multiple series data', () => {\n const tooltipContent: TooltipContentProps = {\n focusedSeries: [\n {\n seriesIdx: 2,\n datumIdx: 48,\n seriesName: 'node_memory_MemFree_bytes{env=\"demo\",instance=\"demo.do.prometheus.io:9100\",job=\"node\"}',\n date: 'Dec 23, 2022, 1:44:00 PM',\n x: 1671821040000,\n y: 84635648,\n formattedY: '84.64M',\n markerColor: 'hsla(1887856572,50%,50%,0.8)',\n },\n {\n seriesIdx: 1,\n datumIdx: 48,\n seriesName: 'node_memory_Buffers_bytes{env=\"demo\",instance=\"demo.do.prometheus.io:9100\",job=\"node\"}',\n date: 'Dec 23, 2022, 1:44:00 PM',\n x: 1671821040000,\n y: 33771520,\n formattedY: '33.77M',\n markerColor: 'hsla(158479636,50%,50%,0.8)',\n },\n ],\n wrapLabels: true,\n };\n renderComponent(tooltipContent);\n expect(screen.getByText('84.64M')).toBeInTheDocument();\n expect(screen.getByText('33.77M')).toBeInTheDocument();\n expect(screen.getAllByText('env=\"demo\", instance=\"demo.do.prometheus.io:9100\", job=\"node\"')).toHaveLength(2);\n });\n});\n"],"names":["render","screen","TooltipContent","describe","renderComponent","props","it","tooltipContent","focusedSeries","seriesIdx","datumIdx","seriesName","date","x","y","formattedY","markerColor","wrapLabels","expect","getByText","toBeInTheDocument","getAllByText","toHaveLength"],"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,SAASC,MAAM,QAAQ,sBAAsB,CAAC;AAC9C,SAASC,cAAc,QAA6B,kBAAkB,CAAC;AAEvEC,QAAQ,CAAC,gBAAgB,EAAE,IAAM;IAC/B,MAAMC,eAAe,GAAG,CAACC,KAA0B,GAAK;QACtDL,MAAM,eAAC,KAACE,cAAc;YAAE,GAAGG,KAAK;UAAI,CAAC,CAAC;IACxC,CAAC,AAAC;IAEFC,EAAE,CAAC,kDAAkD,EAAE,IAAM;QAC3D,MAAMC,cAAc,GAAwB;YAC1CC,aAAa,EAAE;gBACb;oBACEC,SAAS,EAAE,CAAC;oBACZC,QAAQ,EAAE,EAAE;oBACZC,UAAU,EAAE,sCAAsC;oBAClDC,I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EAC5B,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC/B,KAAK,CAAC,EAAE,eAAe,EACvB,IAAI,CAAC,EAAE,WAAW,sBA2CnB"}
@@ -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
@@ -91,9 +91,9 @@ import { TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';
91
91
  if (chart['_model'] === undefined) return [];
92
92
  const chartModel = chart['_model'];
93
93
  const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
94
+ // tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range
94
95
  const seriesNum = chartData.timeSeries.length;
95
- // tooltip trigger area gets smaller with more series
96
- const yBuffer = seriesNum > TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 2;
96
+ const yBuffer = seriesNum > TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 5;
97
97
  var _x, _y;
98
98
  const pointInPixel = [
99
99
  (_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/focused-series.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { formatValue, UnitOptions, EChartsDataFormat } from '../model';\nimport { CursorData, TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';\n\nexport interface FocusedSeriesInfo {\n seriesIdx: number | null;\n datumIdx: number | null;\n seriesName: string;\n date: string;\n markerColor: string;\n x: number;\n y: number;\n formattedY: string;\n}\n\nexport type FocusedSeriesArray = FocusedSeriesInfo[];\n\n/**\n * Returns formatted series data for the points that are close to the user's cursor\n * Adjust yBuffer to increase or decrease number of series shown\n */\nexport function getNearbySeries(\n data: EChartsDataFormat,\n pointInGrid: number[],\n yBuffer: number,\n unit?: UnitOptions\n): FocusedSeriesArray {\n const currentFocusedData: FocusedSeriesArray = [];\n const focusedX: number | null = pointInGrid[0] ?? null;\n const focusedY: number | null = pointInGrid[1] ?? null;\n\n if (focusedX === null || focusedY === null) {\n return currentFocusedData;\n }\n\n if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {\n for (let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++) {\n const currentSeries = data.timeSeries[seriesIdx];\n if (currentFocusedData.length >= TOOLTIP_MAX_ITEMS) break;\n if (currentSeries !== undefined) {\n const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';\n const markerColor = currentSeries.color ?? '#000';\n if (Array.isArray(currentSeries.data)) {\n for (let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++) {\n const xValue = data.xAxis[datumIdx] ?? 0;\n const yValue = currentSeries.data[datumIdx] ?? 0;\n if (focusedX === datumIdx) {\n if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {\n // determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201\n const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;\n const formattedDate = TOOLTIP_DATE_FORMAT.format(xValueMilliSeconds);\n const formattedY = formatValue(yValue, unit);\n currentFocusedData.push({\n seriesIdx: seriesIdx,\n datumIdx: datumIdx,\n seriesName: currentSeriesName,\n date: formattedDate,\n x: xValue,\n y: yValue,\n formattedY: formattedY,\n markerColor: markerColor.toString(),\n });\n }\n }\n }\n }\n }\n }\n }\n return currentFocusedData;\n}\n\n/**\n * Uses mouse position to determine whether user is hovering over a chart canvas\n * If yes, convert from pixel values to logical cartesian coordinates and return all focused series\n */\nexport function getFocusedSeriesData(\n mousePos: CursorData['coords'],\n chartData: EChartsDataFormat,\n pinnedPos: CursorData['coords'],\n chart?: EChartsInstance,\n unit?: UnitOptions\n) {\n if (chart === undefined || mousePos === null) return [];\n\n // prevents multiple tooltips showing from adjacent charts\n let cursorTargetMatchesChart = false;\n if (mousePos.target !== null) {\n const currentParent = (<HTMLElement>mousePos.target).parentElement;\n if (currentParent !== null) {\n const currentGrandparent = currentParent.parentElement;\n if (currentGrandparent !== null) {\n const chartDom = chart.getDom();\n if (chartDom === currentGrandparent) {\n cursorTargetMatchesChart = true;\n }\n }\n }\n }\n\n // allows moving cursor inside tooltip\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n cursorTargetMatchesChart = true;\n }\n\n if (cursorTargetMatchesChart === false) return [];\n\n if (chart['_model'] === undefined) return [];\n const chartModel = chart['_model'];\n const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;\n\n // tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range\n const seriesNum = chartData.timeSeries.length;\n const yBuffer = seriesNum > TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 5;\n\n const pointInPixel = [mousePos.plotCanvas.x ?? 0, mousePos.plotCanvas.y ?? 0];\n if (chart.containPixel('grid', pointInPixel)) {\n const pointInGrid = chart.convertFromPixel('grid', pointInPixel);\n if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {\n return getNearbySeries(chartData, pointInGrid, yBuffer, unit);\n }\n }\n return [];\n}\n"],"names":["formatValue","TOOLTIP_DATE_FORMAT","TOOLTIP_MAX_ITEMS","getNearbySeries","data","pointInGrid","yBuffer","unit","currentFocusedData","focusedX","focusedY","Array","isArray","xAxis","timeSeries","seriesIdx","length","currentSeries","undefined","currentSeriesName","name","toString","markerColor","color","datumIdx","xValue","yValue","xValueMilliSeconds","formattedDate","format","formattedY","push","seriesName","date","x","y","getFocusedSeriesData","mousePos","chartData","pinnedPos","chart","cursorTargetMatchesChart","target","currentParent","parentElement","currentGrandparent","chartDom","getDom","chartModel","yAxisInterval","getComponent","axis","scale","_interval","seriesNum","pointInPixel","plotCanvas","containPixel","convertFromPixel"],"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;AAGjC,SAASA,WAAW,QAAwC,UAAU,CAAC;AACvE,SAAqBC,mBAAmB,EAAEC,iBAAiB,QAAQ,iBAAiB,CAAC;AAerF;;;CAGC,GACD,OAAO,SAASC,eAAe,CAC7BC,IAAuB,EACvBC,WAAqB,EACrBC,OAAe,EACfC,IAAkB,EACE;IACpB,MAAMC,kBAAkB,GAAuB,EAAE,AAAC;QAClBH,GAAc;IAA9C,MAAMI,QAAQ,GAAkBJ,CAAAA,GAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,GAAc,cAAdA,GAAc,GAAI,IAAI,AAAC;QACvBA,IAAc;IAA9C,MAAMK,QAAQ,GAAkBL,CAAAA,IAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,IAAc,cAAdA,IAAc,GAAI,IAAI,AAAC;IAEvD,IAAII,QAAQ,KAAK,IAAI,IAAIC,QAAQ,KAAK,IAAI,EAAE;QAC1C,OAAOF,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAIG,KAAK,CAACC,OAAO,CAACR,IAAI,CAACS,KAAK,CAAC,IAAIF,KAAK,CAACC,OAAO,CAACR,IAAI,CAACU,UAAU,CAAC,EAAE;QAC/D,IAAK,IAAIC,SAAS,GAAG,CAAC,EAAEA,SAAS,GAAGX,IAAI,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AACmC,SAAS,EAAEjC,WAAW,EAAEC,OAAO,EAAEC,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focused-series.test.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/focused-series.test.ts"],"names":[],"mappings":""}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/focused-series.test.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { EChartsDataFormat, UnitOptions } from '../model';\nimport { getNearbySeries } from './focused-series';\n\ndescribe('getNearbySeries', () => {\n const chartData: EChartsDataFormat = {\n timeSeries: [\n {\n type: 'line',\n name: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test\"',\n color: 'hsla(-1365438424,50%,50%,0.8)',\n data: [\n 0.0002315202231525094, 0.00022873082287300112, 0.00023152022315149463, 0.00023152022315149463,\n 0.00022873082287300112,\n ],\n symbol: 'circle',\n },\n {\n type: 'line',\n name: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test alt\"',\n color: 'hsla(286664040,50%,50%,0.8)',\n data: [0.05245188284519867, 0.0524463040446356, 0.0524463040446356, 0.05247140864723438, 0.052482566248230646],\n symbol: 'circle',\n },\n ],\n xAxis: [1654007865000, 1654007880000, 1654007895000, 1654007910000, 1654007925000],\n rangeMs: 60000,\n };\n\n // https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel\n const pointInGrid = [2, 0.0560655737704918]; // converted from chart.getZr() mousemove coordinates\n\n const yBuffer = 0.02; // calculated from y axis interval\n\n const focusedSeriesOutput = [\n {\n date: 'May 31, 2022, 2:38:15 PM',\n datumIdx: 2,\n markerColor: 'hsla(286664040,50%,50%,0.8)',\n seriesName: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test alt\"',\n seriesIdx: 1,\n x: 1654007895000,\n y: 0.0524463040446356,\n formattedY: '0.05',\n },\n ];\n\n it('should return focused series data for points nearby the cursor', () => {\n const decimalUnit: UnitOptions = {\n kind: 'Decimal',\n decimal_places: 2,\n };\n expect(getNearbySeries(chartData, pointInGrid, yBuffer, decimalUnit)).toEqual(focusedSeriesOutput);\n });\n\n it('should return series values formatted as a percent', () => {\n const percentFormattedOutput = [...focusedSeriesOutput];\n if (percentFormattedOutput[0]) {\n percentFormattedOutput[0].formattedY = '5%';\n }\n const percentFormattedUnit: UnitOptions = {\n kind: 'PercentDecimal',\n decimal_places: 0,\n };\n expect(getNearbySeries(chartData, pointInGrid, yBuffer, percentFormattedUnit)).toEqual(percentFormattedOutput);\n });\n});\n"],"names":["getNearbySeries","describe","chartData","timeSeries","type","name","color","data","symbol","xAxis","rangeMs","pointInGrid","yBuffer","focusedSeriesOutput","date","datumIdx","markerColor","seriesName","seriesIdx","x","y","formattedY","it","decimalUnit","kind","decimal_places","expect","toEqual","percentFormattedOutput","percentFormattedUnit"],"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;AAGjC,SAASA,eAAe,QAAQ,kBAAkB,C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CAACE,SAAS,EAAES,WAAW,EAAEC,OAAO,EAAEW,WAAW,CAAC,CAAC,CAACI,OAAO,CAACd,mBAAmB,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;IAEHS,EAAE,CAAC,oDAAoD,EAAE,IAAM;QAC7D,MAAMM,sBAAsB,GAAG;eAAIf,mBAAmB;SAAC,AAAC;QACxD,IAAIe,sBAAsB,CAAC,CAAC,CAAC,EAAE;YAC7BA,sBAAsB,CAAC,CAAC,CAAC,CAACP,UAAU,GAAG,IAAI,CAAC;QAC9C,CAAC;QACD,MAAMQ,oBAAoB,GAAgB;YACxCL,IAAI,EAAE,gBAAgB;YACtBC,cAAc,EAAE,CAAC;SAClB,AAAC;QACFC,MAAM,CAAC1B,eAAe,CAACE,SAAS,EAAES,WAAW,EAAEC,OAAO,EAAEiB,oBAAoB,CAAC,CAAC,CAACF,OAAO,CAACC,sBAAsB,CAAC,CAAC;IACjH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './TimeSeriesTooltip';
2
+ export * from './SeriesInfo';
3
+ export * from './SeriesLabelsStack';
4
+ export * from './SeriesMarker';
5
+ export * from './TooltipContent';
6
+ export * from './focused-series';
7
+ export * from './tooltip-model';
8
+ export * from './utils';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,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
@@ -10,7 +10,13 @@
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
- export * from './Tooltip';
13
+ export * from './TimeSeriesTooltip';
14
+ export * from './SeriesInfo';
15
+ export * from './SeriesLabelsStack';
14
16
  export * from './SeriesMarker';
17
+ export * from './TooltipContent';
18
+ export * from './focused-series';
19
+ export * from './tooltip-model';
20
+ export * from './utils';
15
21
 
16
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/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 './TimeSeriesTooltip';\nexport * from './SeriesInfo';\nexport * from './SeriesLabelsStack';\nexport * from './SeriesMarker';\nexport * from './TooltipContent';\nexport * from './focused-series';\nexport * from './tooltip-model';\nexport * from './utils';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,i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AC,EAAE,cAAc,GAAG,gBAAgB,CAAC;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,oBAAY,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAAC;AAE7D,eAAO,MAAM,gBAAgB,QAAO,UAAU,CAAC,QAAQ,CAgCtD,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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/tooltip-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useEffect, useState } from 'react';\nimport { FocusedSeriesArray } from './focused-series';\n\nexport const TOOLTIP_MAX_WIDTH = 650;\nexport const TOOLTIP_MAX_HEIGHT = 230;\nexport const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;\n\nexport const TOOLTIP_MAX_ITEMS = 50;\n\nexport const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n hour12: true,\n});\n\nexport const defaultCursorData = {\n coords: {\n viewport: {\n x: 0,\n y: 0,\n },\n plotCanvas: {\n x: 0,\n y: 0,\n },\n zrender: {\n x: 0,\n y: 0,\n },\n target: null,\n },\n chartWidth: 0,\n};\n\nexport const emptyTooltipData = {\n cursor: defaultCursorData,\n focusedSeries: null,\n};\n\nexport interface CursorCoordinates {\n viewport: {\n x: number;\n y: number;\n };\n plotCanvas: {\n x: number;\n y: number;\n };\n zrender: {\n x?: number;\n y?: number;\n };\n target: EventTarget | null;\n}\n\nexport interface CursorData {\n coords: CursorCoordinates | null;\n chartWidth?: number;\n}\n\nexport interface TooltipData {\n focusedSeries: FocusedSeriesArray | null;\n cursor: CursorData;\n}\n\ntype ZREventProperties = {\n zrX?: number;\n zrY?: number;\n zrDelta?: number;\n zrEventControl?: 'no_globalout' | 'only_globalout';\n zrByTouch?: boolean;\n};\n\nexport type ZRRawMouseEvent = MouseEvent & ZREventProperties;\n\nexport const useMousePosition = (): CursorData['coords'] => {\n const [coords, setCoords] = useState<CursorData['coords']>(null);\n\n useEffect(() => {\n const setFromEvent = (e: ZRRawMouseEvent) => {\n return setCoords({\n viewport: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.offsetX,\n y: e.offsetY,\n },\n zrender: {\n // echarts canvas coordinates added automatically by zrender\n // zrX and zrY are similar to offsetX and offsetY but they return undefined when not hovering over a chart canvas\n x: e.zrX,\n y: e.zrY,\n },\n // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)\n target: e.target,\n });\n };\n window.addEventListener('mousemove', setFromEvent);\n\n return () => {\n window.removeEventListener('mousemove', setFromEvent);\n };\n }, []);\n\n return coords;\n};\n"],"names":["useEffect","useState","TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_LABELS_MAX_WIDTH","TOOLTIP_MAX_ITEMS","TOOLTIP_DATE_FORMAT","Intl","DateTimeFormat","undefined","year","month","day","hour","minute","second","hour12","defaultCursorData","coords","viewport","x","y","plotCanvas","zrender","target","chartWidth","emptyTooltipData","cursor","focusedSeries","useMousePosition","setCoords","setFromEvent","e","clientX","clientY","offsetX","offsetY","zrX","zrY","window","addEventListener","removeEventListener"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE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AAC,IAAM;QACd,MAAM+B,YAAY,GAAG,CAACC,CAAkB,GAAK;YAC3C,OAAOF,SAAS,CAAC;gBACfX,QAAQ,EAAE;oBACRC,CAAC,EAAEY,CAAC,CAACC,OAAO;oBACZZ,CAAC,EAAEW,CAAC,CAACE,OAAO;iBACb;gBACDZ,UAAU,EAAE;oBACVF,CAAC,EAAEY,CAAC,CAACG,OAAO;oBACZd,CAAC,EAAEW,CAAC,CAACI,OAAO;iBACb;gBACDb,OAAO,EAAE;oBACP,4DAA4D;oBAC5D,iHAAiH;oBACjHH,CAAC,EAAEY,CAAC,CAACK,GAAG;oBACRhB,CAAC,EAAEW,CAAC,CAACM,GAAG;iBACT;gBACD,0HAA0H;gBAC1Hd,MAAM,EAAEQ,CAAC,CAACR,MAAM;aACjB,CAAC,CAAC;QACL,CAAC,AAAC;QACFe,MAAM,CAACC,gBAAgB,CAAC,WAAW,EAAET,YAAY,CAAC,CAAC;QAEnD,OAAO,IAAM;YACXQ,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAEV,YAAY,CAAC,CAAC;QACxD,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAOb,MAAM,CAAC;AAChB,CAAC,CAAC"}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAqB,MAAM,iBAAiB,CAAC;AAEnF;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC9B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,iBAAiB,GAAG,IAAI,UAoCpC"}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/utils.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { CursorCoordinates, CursorData, TOOLTIP_MAX_WIDTH } from './tooltip-model';\n\n/**\n * Determine position of tooltip depending on chart dimensions and the number of focused series\n */\nexport function assembleTransform(\n mousePos: CursorData['coords'],\n seriesNum: number,\n chartWidth: number,\n chartHeight: number,\n pinnedPos: CursorCoordinates | null\n) {\n if (mousePos === null) {\n return 'translate3d(0, 0)';\n }\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n const x = mousePos.viewport.x;\n let y = mousePos.viewport.y + cursorPaddingY;\n\n const isCloseToBottom = mousePos.viewport.y > window.innerHeight * 0.8;\n const yPosAdjustThreshold = chartHeight * 0.75;\n // adjust so tooltip does not get cut off at bottom of chart, reduce multiplier to move up\n if (isCloseToBottom === true) {\n if (seriesNum > 6) {\n y = mousePos.viewport.y * 0.65;\n } else {\n y = mousePos.viewport.y * 0.75;\n }\n } else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {\n y = mousePos.viewport.y * 0.85;\n }\n\n // use tooltip width to determine when to repos from right to left (width is narrower when only 1 focused series since labels wrap)\n const tooltipWidth = seriesNum > 1 ? TOOLTIP_MAX_WIDTH : TOOLTIP_MAX_WIDTH / 2;\n const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;\n\n // reposition so tooltip is never too close to right side of chart or left side of browser window\n return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH\n ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`\n : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;\n}\n"],"names":["TOOLTIP_MAX_WIDTH","assembleTransform","mousePos","seriesNum","chartWidth","chartHeight","pinnedPos","cursorPaddingX","cursorPaddingY","x","viewport","y","isCloseToBottom","window","innerHeight","yPosAdjustThreshold","plotCanvas","tooltipWidth","xPosAdjustThreshold"],"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,SAAwCA,iBAAiB,QAAQ,iBAAiB,CAAC;AAEnF;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAC/BC,QAA8B,EAC9BC,SAAiB,EACjBC,UAAkB,EAClBC,WAAmB,EACnBC,SAAmC,EACnC;IACA,IAAIJ,QAAQ,KAAK,IAAI,EAAE;QACrB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,IAAII,SAAS,KAAK,IAAI,EAAE;QACtBJ,QAAQ,GAAGI,SAAS,CAAC;IACvB,CAAC;IAED,MAAMC,cAAc,GAAG,EAAE,AAAC;IAC1B,MAAMC,cAAc,GAAG,EAAE,AAAC;IAC1B,MAAMC,CAAC,GAAGP,QAAQ,CAACQ,QAAQ,CAACD,CAAC,AAAC;IAC9B,IAAIE,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAGH,cAAc,AAAC;IAE7C,MAAMI,eAAe,GAAGV,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAGE,MAAM,CAACC,WAAW,GAAG,GAAG,AAAC;IACvE,MAAMC,mBAAmB,GAAGV,WAAW,GAAG,IAAI,AAAC;IAC/C,0FAA0F;IAC1F,IAAIO,eAAe,KAAK,IAAI,EAAE;QAC5B,IAAIT,SAAS,GAAG,CAAC,EAAE;YACjBQ,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAG,IAAI,CAAC;QACjC,OAAO;YACLA,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAG,IAAI,CAAC;QACjC,CAAC;IACH,OAAO,IAAIT,QAAQ,CAACc,UAAU,CAACL,CAAC,GAAGI,mBAAmB,EAAE;QACtDJ,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,mIAAmI;IACnI,MAAMM,YAAY,GAAGd,SAAS,GAAG,CAAC,GAAGH,iBAAiB,GAAGA,iBAAiB,GAAG,CAAC,AAAC;IAC/E,MAAMkB,mBAAmB,GAAGd,UAAU,GAAGa,YAAY,GAAG,GAAG,AAAC;IAE5D,iGAAiG;IACjG,OAAOf,QAAQ,CAACc,UAAU,CAACP,CAAC,GAAGS,mBAAmB,IAAIT,CAAC,GAAGT,iBAAiB,GACvE,CAAC,YAAY,EAAES,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,wBAAwB,CAAC,GACnE,CAAC,YAAY,EAAEF,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,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/UnitSelector/UnitSelector.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.\nimport { Box, Switch, TextField, Autocomplete, SwitchProps } from '@mui/material';\nimport {\n UnitOptions,\n UNIT_CONFIG,\n DEFAULT_DECIMAL_PLACES,\n UnitConfig,\n isUnitWithDecimalPlaces,\n isUnitWithAbbreviate,\n} from '../model';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\n\nexport interface UnitSelectorProps {\n value: UnitOptions;\n onChange: (unit: UnitOptions) => void;\n}\n\ntype AutocompleteKindOption = UnitConfig & { id: UnitOptions['kind'] };\n\nconst KIND_OPTIONS: AutocompleteKindOption[] = Object.entries(UNIT_CONFIG)\n .map(([id, config]) => {\n return {\n id: id as UnitOptions['kind'],\n ...config,\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nconst DECIMAL_OPTIONS = [0, 1, 2, 3, 4];\n\nexport function UnitSelector({ value, onChange }: UnitSelectorProps) {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasAbbreviate = isUnitWithAbbreviate(value);\n\n const handleKindChange = (_: unknown, newValue: AutocompleteKindOption) => {\n onChange({\n kind: newValue.id,\n });\n };\n\n const handleDecimalChange = (_: unknown, newValue: number) => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimal_places: newValue,\n });\n }\n };\n\n const handleAbbreviateChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasAbbreviate) {\n onChange({\n ...value,\n abbreviate: checked,\n });\n }\n };\n\n const kindConfig = UNIT_CONFIG[value.kind];\n\n return (\n <>\n <OptionsEditorControl\n label=\"Abbreviate\"\n control={\n <Switch\n checked={hasAbbreviate ? !!value.abbreviate : false}\n onChange={handleAbbreviateChange}\n disabled={!hasAbbreviate}\n />\n }\n />\n <OptionsEditorControl\n label=\"Units\"\n control={\n <Autocomplete\n value={{ id: value.kind, ...kindConfig }}\n options={KIND_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n groupBy={(option) => option.group}\n renderInput={(params) => <TextField {...params} />}\n renderOption={(renderOptsProps, option) => {\n // Custom option needed to get some increased left padding to make\n // the items more distinct from the group label.\n return (\n <li {...renderOptsProps}>\n <Box paddingLeft={(theme) => theme.spacing(1)}>{option.label}</Box>\n </li>\n );\n }}\n onChange={handleKindChange}\n disableClearable\n ></Autocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Decimal\"\n control={\n <Autocomplete\n value={hasDecimalPlaces ? value.decimal_places ?? DEFAULT_DECIMAL_PLACES : 0}\n options={DECIMAL_OPTIONS}\n getOptionLabel={(option) => `${option}`}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleDecimalChange}\n disabled={!hasDecimalPlaces}\n disableClearable\n ></Autocomplete>\n }\n />\n </>\n );\n}\n"],"names":["Box","Switch","TextField","Autocomplete","UNIT_CONFIG","DEFAULT_DECIMAL_PLACES","isUnitWithDecimalPlaces","isUnitWithAbbreviate","OptionsEditorControl","KIND_OPTIONS","Object","entries","map","id","config","filter","disableSelectorOption","DECIMAL_OPTIONS","UnitSelector","value","onChange","hasDecimalPlaces","hasAbbreviate","handleKindChange","_","newValue","kind","handleDecimalChange","decimal_places","handleAbbreviateChange","checked","abbreviate","kindConfig","label","control","disabled","options","isOptionEqualToValue","option","groupBy","group","renderInput","params","renderOption","renderOptsProps","li","paddingLeft","theme","spacing","disableClearable","getOptionLabel"],"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;AACjC;AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,SAAS,EAAEC,YAAY,QAAqB,eAAe,CAAC;AAClF,SAEEC,WAAW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ACXgB,KAAK,EAAEE,gBAAgB,GAAGF,CAAAA,eAAoB,GAApBA,KAAK,CAACS,cAAc,cAApBT,eAAoB,cAApBA,eAAoB,GAAId,sBAAsB,GAAG,CAAC;oBAC5E+B,OAAO,EAAEnB,eAAe;oBACxBiC,cAAc,EAAE,CAACZ,MAAM,GAAK,CAAC,EAAEA,MAAM,CAAC,CAAC;oBACvCG,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACxC,SAAS;4BAAE,GAAGwC,MAAM;0BAAI;oBAClDtB,QAAQ,EAAEO,mBAAmB;oBAC7BQ,QAAQ,EAAE,CAACd,gBAAgB;oBAC3B4B,gBAAgB;kBACF;cAElB;;MACD,CACH;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/UnitSelector/UnitSelector.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.\nimport { Box, Switch, TextField, Autocomplete, SwitchProps } from '@mui/material';\nimport {\n UnitOptions,\n UNIT_CONFIG,\n DEFAULT_DECIMAL_PLACES,\n UnitConfig,\n isUnitWithDecimalPlaces,\n isUnitWithAbbreviate,\n} from '../model';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\n\nexport interface UnitSelectorProps {\n value: UnitOptions;\n onChange: (unit: UnitOptions) => void;\n}\n\ntype AutocompleteKindOption = UnitConfig & { id: UnitOptions['kind'] };\n\nconst KIND_OPTIONS: AutocompleteKindOption[] = Object.entries(UNIT_CONFIG)\n .map(([id, config]) => {\n return {\n id: id as UnitOptions['kind'],\n ...config,\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nconst DECIMAL_OPTIONS = [0, 1, 2, 3, 4];\n\nexport function UnitSelector({ value, onChange }: UnitSelectorProps) {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasAbbreviate = isUnitWithAbbreviate(value);\n\n const handleKindChange = (_: unknown, newValue: AutocompleteKindOption) => {\n onChange({\n kind: newValue.id,\n });\n };\n\n const handleDecimalChange = (_: unknown, newValue: number) => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimal_places: newValue,\n });\n }\n };\n\n const handleAbbreviateChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasAbbreviate) {\n onChange({\n ...value,\n abbreviate: checked,\n });\n }\n };\n\n const kindConfig = UNIT_CONFIG[value.kind];\n\n return (\n <>\n <OptionsEditorControl\n label=\"Abbreviate\"\n control={\n <Switch\n checked={hasAbbreviate ? !!value.abbreviate : false}\n onChange={handleAbbreviateChange}\n disabled={!hasAbbreviate}\n />\n }\n />\n <OptionsEditorControl\n label=\"Units\"\n control={\n <Autocomplete\n value={{ id: value.kind, ...kindConfig }}\n options={KIND_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n groupBy={(option) => option.group}\n renderInput={(params) => <TextField {...params} />}\n renderOption={(renderOptsProps, option) => {\n // Custom option needed to get some increased left padding to make\n // the items more distinct from the group label.\n return (\n <li {...renderOptsProps}>\n <Box paddingLeft={(theme) => theme.spacing(1)}>{option.label}</Box>\n </li>\n );\n }}\n onChange={handleKindChange}\n disableClearable\n ></Autocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Decimal\"\n control={\n <Autocomplete\n value={hasDecimalPlaces ? value.decimal_places ?? DEFAULT_DECIMAL_PLACES : 0}\n options={DECIMAL_OPTIONS}\n getOptionLabel={(option) => `${option}`}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleDecimalChange}\n disabled={!hasDecimalPlaces}\n disableClearable\n ></Autocomplete>\n }\n />\n </>\n );\n}\n"],"names":["Box","Switch","TextField","Autocomplete","UNIT_CONFIG","DEFAULT_DECIMAL_PLACES","isUnitWithDecimalPlaces","isUnitWithAbbreviate","OptionsEditorControl","KIND_OPTIONS","Object","entries","map","id","config","filter","disableSelectorOption","DECIMAL_OPTIONS","UnitSelector","value","onChange","hasDecimalPlaces","hasAbbreviate","handleKindChange","_","newValue","kind","handleDecimalChange","decimal_places","handleAbbreviateChange","checked","abbreviate","kindConfig","label","control","disabled","options","isOptionEqualToValue","option","groupBy","group","renderInput","params","renderOption","renderOptsProps","li","paddingLeft","theme","spacing","disableClearable","getOptionLabel"],"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;AACjC;AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,SAAS,EAAEC,YAAY,QAAqB,eAAe,CAAC;AAClF,SAEEC,WAAW,EACXC,sBAAsB,EAEtBC,uBAAuB,EACvBC,oBAAoB,QACf,UAAU,CAAC;AAClB,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAS9D,MAAMC,YAAY,GAA6BC,MAAM,CAACC,OAAO,CAACP,WAAW,CAAC,CACvEQ,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IACrB,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,CACDC,MAAM,CAAC,CAACD,MAAM,GAAK,CAACA,MAAM,CAACE,qBAAqB,CAAC,AAAC;AAErD,MAAMC,eAAe,GAAG;AAAC,KAAC;AAAE,KAAC;AAAE,KAAC;AAAE,KAAC;AAAE,KAAC;CAAC,AAAC;AAExC,OAAO,SAASC,YAAY,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAqB,EAAE;IACnE,MAAMC,gBAAgB,GAAGf,uBAAuB,CAACa,KAAK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AE,KAAKM,KAAK,CAACN,EAAE;oBAC/D0B,OAAO,EAAE,CAACD,MAAM,GAAKA,MAAM,CAACE,KAAK;oBACjCC,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACxC,SAAS;4BAAE,GAAGwC,MAAM;0BAAI;oBAClDC,YAAY,EAAE,CAACC,eAAe,EAAEN,MAAM,GAAK;wBACzC,kEAAkE;wBAClE,gDAAgD;wBAChD,qBACE,KAACO,IAAE;4BAAE,GAAGD,eAAe;sCACrB,cAAA,KAAC5C,GAAG;gCAAC8C,WAAW,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;0CAAGV,MAAM,CAACL,KAAK;8BAAO;0BAChE,CACL;oBACJ,CAAC;oBACDb,QAAQ,EAAEG,gBAAgB;oBAC1B0B,gBAAgB;kBACF;cAElB;0BACF,KAACzC,oBAAoB;gBACnByB,KAAK,EAAC,SAAS;gBACfC,OAAO,gBACL,KAAC/B,YAAY;oBACXgB,KAAK,EAAEE,gBAAgB,GAAGF,CAAAA,eAAoB,GAApBA,KAAK,CAACS,cAAc,cAApBT,eAAoB,cAApBA,eAAoB,GAAId,sBAAsB,GAAG,CAAC;oBAC5E+B,OAAO,EAAEnB,eAAe;oBACxBiC,cAAc,EAAE,CAACZ,MAAM,GAAK,CAAC,EAAEA,MAAM,CAAC,CAAC;oBACvCG,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACxC,SAAS;4BAAE,GAAGwC,MAAM;0BAAI;oBAClDtB,QAAQ,EAAEO,mBAAmB;oBAC7BQ,QAAQ,EAAE,CAACd,gBAAgB;oBAC3B4B,gBAAgB;kBACF;cAElB;;MACD,CACH;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/UnitSelector/UnitSelector.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, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { UnitOptions } from '../model';\nimport { UnitSelector } from './UnitSelector';\n\ndescribe('UnitSelector', () => {\n const renderUnitSelector = (value: UnitOptions, onChange = jest.fn()) => {\n render(\n <div>\n <UnitSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getUnitSelector = () => {\n return screen.getByRole('combobox', { name: 'Units' });\n };\n\n const getDecimalSelector = () => {\n return screen.getByRole('combobox', { name: 'Decimal' });\n };\n\n const getAbbreviateSwitch = () => {\n return screen.getByRole('checkbox', { name: 'Abbreviate' });\n };\n\n it('can change the unit kind by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Minutes' }, onChange);\n\n const unitSelector = getUnitSelector();\n userEvent.click(unitSelector);\n const decimalOption = screen.getByRole('option', {\n name: 'Decimal',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n });\n });\n\n it('can change the unit kind using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Bytes' }, onChange);\n\n const unitSelector = getUnitSelector();\n userEvent.tab();\n userEvent.tab();\n expect(unitSelector).toHaveFocus();\n\n userEvent.clear(unitSelector);\n userEvent.keyboard('years');\n screen.getByRole('option', {\n name: 'Years',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Years',\n });\n });\n\n it('can change the decimal places by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0, abbreviate: true }, onChange);\n\n userEvent.click(getDecimalSelector());\n const decimalOption = screen.getByRole('option', {\n name: '1',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 1,\n abbreviate: true,\n });\n });\n\n it('can change the decimal places using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Percent' }, onChange);\n\n const decimalSelector = getDecimalSelector();\n userEvent.tab();\n userEvent.tab();\n expect(decimalSelector).toHaveFocus();\n\n userEvent.clear(decimalSelector);\n userEvent.keyboard('3');\n screen.getByRole('option', {\n name: '3',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Percent',\n decimal_places: 3,\n });\n });\n\n it('can change abbreviate by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 3, abbreviate: true }, onChange);\n\n userEvent.click(getAbbreviateSwitch());\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 3,\n abbreviate: false,\n });\n });\n\n it('can change abbreviate using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0 }, onChange);\n\n userEvent.tab();\n userEvent.keyboard('{space}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 0,\n abbreviate: true,\n });\n });\n\n describe('with a time unit selected', () => {\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Minutes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a percent unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Percent' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'PercentDecimal' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a decimal unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('allows the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getAbbreviateSwitch()).toBeEnabled();\n });\n });\n\n describe('with a bytes unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('allows the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getAbbreviateSwitch()).toBeEnabled();\n });\n });\n\n it('should not show an option for disabled units', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal' }, onChange);\n\n userEvent.click(getUnitSelector());\n const percentShorthandOption = screen.queryByRole('option', {\n name: '%',\n });\n expect(percentShorthandOption).not.toBeInTheDocument();\n });\n});\n"],"names":["render","screen","userEvent","UnitSelector","describe","renderUnitSelector","value","onChange","jest","fn","div","getUnitSelector","getByRole","name","getDecimalSelector","getAbbreviateSwitch","it","kind","unitSelector","click","decimalOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard","decimal_places","abbreviate","decimalSelector","toBeDisabled","toBeEnabled","percentShorthandOption","queryByRole","not","toBeInTheDocument"],"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,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAE9CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,kBAAkB,GAAG,CAACC,KA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AAC,QAAQ,EAAE;YAC1DpB,IAAI,EAAE,GAAG;SACV,CAAC,AAAC;QACHQ,MAAM,CAACW,sBAAsB,CAAC,CAACE,GAAG,CAACC,iBAAiB,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/UnitSelector/UnitSelector.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, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { UnitOptions } from '../model';\nimport { UnitSelector } from './UnitSelector';\n\ndescribe('UnitSelector', () => {\n const renderUnitSelector = (value: UnitOptions, onChange = jest.fn()) => {\n render(\n <div>\n <UnitSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getUnitSelector = () => {\n return screen.getByRole('combobox', { name: 'Units' });\n };\n\n const getDecimalSelector = () => {\n return screen.getByRole('combobox', { name: 'Decimal' });\n };\n\n const getAbbreviateSwitch = () => {\n return screen.getByRole('checkbox', { name: 'Abbreviate' });\n };\n\n it('can change the unit kind by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Minutes' }, onChange);\n\n const unitSelector = getUnitSelector();\n userEvent.click(unitSelector);\n const decimalOption = screen.getByRole('option', {\n name: 'Decimal',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n });\n });\n\n it('can change the unit kind using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Bytes' }, onChange);\n\n const unitSelector = getUnitSelector();\n userEvent.tab();\n userEvent.tab();\n expect(unitSelector).toHaveFocus();\n\n userEvent.clear(unitSelector);\n userEvent.keyboard('years');\n screen.getByRole('option', {\n name: 'Years',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Years',\n });\n });\n\n it('can change the decimal places by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0, abbreviate: true }, onChange);\n\n userEvent.click(getDecimalSelector());\n const decimalOption = screen.getByRole('option', {\n name: '1',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 1,\n abbreviate: true,\n });\n });\n\n it('can change the decimal places using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Percent' }, onChange);\n\n const decimalSelector = getDecimalSelector();\n userEvent.tab();\n userEvent.tab();\n expect(decimalSelector).toHaveFocus();\n\n userEvent.clear(decimalSelector);\n userEvent.keyboard('3');\n screen.getByRole('option', {\n name: '3',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Percent',\n decimal_places: 3,\n });\n });\n\n it('can change abbreviate by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 3, abbreviate: true }, onChange);\n\n userEvent.click(getAbbreviateSwitch());\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 3,\n abbreviate: false,\n });\n });\n\n it('can change abbreviate using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0 }, onChange);\n\n userEvent.tab();\n userEvent.keyboard('{space}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 0,\n abbreviate: true,\n });\n });\n\n describe('with a time unit selected', () => {\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Minutes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a percent unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Percent' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'PercentDecimal' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a decimal unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('allows the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getAbbreviateSwitch()).toBeEnabled();\n });\n });\n\n describe('with a bytes unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('allows the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getAbbreviateSwitch()).toBeEnabled();\n });\n });\n\n it('should not show an option for disabled units', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal' }, onChange);\n\n userEvent.click(getUnitSelector());\n const percentShorthandOption = screen.queryByRole('option', {\n name: '%',\n });\n expect(percentShorthandOption).not.toBeInTheDocument();\n });\n});\n"],"names":["render","screen","userEvent","UnitSelector","describe","renderUnitSelector","value","onChange","jest","fn","div","getUnitSelector","getByRole","name","getDecimalSelector","getAbbreviateSwitch","it","kind","unitSelector","click","decimalOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard","decimal_places","abbreviate","decimalSelector","toBeDisabled","toBeEnabled","percentShorthandOption","queryByRole","not","toBeInTheDocument"],"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,M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,AAAC;QAC3BJ,kBAAkB,CAAC;YAAEY,IAAI,EAAE,SAAS;SAAE,EAAEV,QAAQ,CAAC,CAAC;QAElDL,SAAS,CAACiB,KAAK,CAACR,eAAe,EAAE,CAAC,CAAC;QACnC,MAAMqB,sBAAsB,GAAG/B,MAAM,CAACgC,WAAW,CAAC,QAAQ,EAAE;YAC1DpB,IAAI,EAAE,GAAG;SACV,CAAC,AAAC;QACHQ,MAAM,CAACW,sBAAsB,CAAC,CAACE,GAAG,CAACC,iBAAiB,EAAE,CAAC;IACzD,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/UnitSelector/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 './UnitSelector';\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,gBAAgB,CAAC"}
1
+ {"version":3,"sources":["../../src/UnitSelector/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 './UnitSelector';\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,gBAAgB,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