@perses-dev/components 0.54.0-beta.0 → 0.54.0-beta.2

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 (330) hide show
  1. package/dist/AlignSelector/AlignSelector.js +1 -1
  2. package/dist/AlignSelector/AlignSelector.js.map +1 -1
  3. package/dist/ColorPicker/ColorPicker.js +1 -1
  4. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  5. package/dist/ColorPicker/OptionsColorPicker.js +1 -1
  6. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  7. package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
  8. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  9. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
  10. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  11. package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
  12. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  13. package/dist/Dialog/DiscardChangesConfirmationDialog.js +1 -1
  14. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  15. package/dist/DragAndDrop/DragAndDropList.js +1 -1
  16. package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
  17. package/dist/DragAndDrop/DragButton.js +1 -1
  18. package/dist/DragAndDrop/DragButton.js.map +1 -1
  19. package/dist/DragAndDrop/DropIndicator.js +1 -1
  20. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  21. package/dist/Drawer/Drawer.js +1 -1
  22. package/dist/Drawer/Drawer.js.map +1 -1
  23. package/dist/EChart/EChart.js +1 -1
  24. package/dist/EChart/EChart.js.map +1 -1
  25. package/dist/ErrorAlert.js +1 -1
  26. package/dist/ErrorAlert.js.map +1 -1
  27. package/dist/FormEditor/FormActions.d.ts +1 -1
  28. package/dist/FormEditor/FormActions.d.ts.map +1 -1
  29. package/dist/FormEditor/FormActions.js +1 -1
  30. package/dist/FormEditor/FormActions.js.map +1 -1
  31. package/dist/FormatControls/FormatControls.d.ts +1 -1
  32. package/dist/FormatControls/FormatControls.d.ts.map +1 -1
  33. package/dist/FormatControls/FormatControls.js +2 -2
  34. package/dist/FormatControls/FormatControls.js.map +1 -1
  35. package/dist/FormatControls/UnitSelector.d.ts +1 -1
  36. package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
  37. package/dist/FormatControls/UnitSelector.js +1 -1
  38. package/dist/FormatControls/UnitSelector.js.map +1 -1
  39. package/dist/JSONEditor.js +1 -1
  40. package/dist/JSONEditor.js.map +1 -1
  41. package/dist/Legend/CompactLegend.js +1 -1
  42. package/dist/Legend/CompactLegend.js.map +1 -1
  43. package/dist/Legend/Legend.js +2 -2
  44. package/dist/Legend/Legend.js.map +1 -1
  45. package/dist/Legend/LegendColorBadge.js +1 -1
  46. package/dist/Legend/LegendColorBadge.js.map +1 -1
  47. package/dist/Legend/ListLegend.js +1 -1
  48. package/dist/Legend/ListLegend.js.map +1 -1
  49. package/dist/Legend/ListLegendItem.js +1 -1
  50. package/dist/Legend/ListLegendItem.js.map +1 -1
  51. package/dist/Legend/TableLegend.d.ts.map +1 -1
  52. package/dist/Legend/TableLegend.js +18 -4
  53. package/dist/Legend/TableLegend.js.map +1 -1
  54. package/dist/Legend/legend-model.d.ts +1 -1
  55. package/dist/Legend/legend-model.d.ts.map +1 -1
  56. package/dist/Legend/legend-model.js.map +1 -1
  57. package/dist/LinksEditor/LinkEditorForm.js +1 -1
  58. package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
  59. package/dist/LinksEditor/LinksEditor.js +1 -1
  60. package/dist/LinksEditor/LinksEditor.js.map +1 -1
  61. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
  62. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  63. package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  64. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  65. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
  66. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  67. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
  68. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  69. package/dist/Overlay/Overlay.js +1 -1
  70. package/dist/Overlay/Overlay.js.map +1 -1
  71. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
  72. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  73. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -1
  74. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  75. package/dist/SortSelector/SortSelectorButtons.js +1 -1
  76. package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
  77. package/dist/Table/InnerTable.js +1 -1
  78. package/dist/Table/InnerTable.js.map +1 -1
  79. package/dist/Table/Table.d.ts +1 -1
  80. package/dist/Table/Table.d.ts.map +1 -1
  81. package/dist/Table/Table.js +47 -14
  82. package/dist/Table/Table.js.map +1 -1
  83. package/dist/Table/TableBody.js +1 -1
  84. package/dist/Table/TableBody.js.map +1 -1
  85. package/dist/Table/TableCell.js +1 -1
  86. package/dist/Table/TableCell.js.map +1 -1
  87. package/dist/Table/TableCheckbox.js +1 -1
  88. package/dist/Table/TableCheckbox.js.map +1 -1
  89. package/dist/Table/TableFoot.js +1 -1
  90. package/dist/Table/TableFoot.js.map +1 -1
  91. package/dist/Table/TableHead.js +1 -1
  92. package/dist/Table/TableHead.js.map +1 -1
  93. package/dist/Table/TableHeaderCell.d.ts +20 -1
  94. package/dist/Table/TableHeaderCell.d.ts.map +1 -1
  95. package/dist/Table/TableHeaderCell.js +56 -24
  96. package/dist/Table/TableHeaderCell.js.map +1 -1
  97. package/dist/Table/TableRow.js +1 -1
  98. package/dist/Table/TableRow.js.map +1 -1
  99. package/dist/Table/TableToolbar.d.ts +46 -0
  100. package/dist/Table/TableToolbar.d.ts.map +1 -0
  101. package/dist/Table/TableToolbar.js +138 -0
  102. package/dist/Table/TableToolbar.js.map +1 -0
  103. package/dist/Table/VirtualizedTable.d.ts +7 -3
  104. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  105. package/dist/Table/VirtualizedTable.js +157 -123
  106. package/dist/Table/VirtualizedTable.js.map +1 -1
  107. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
  108. package/dist/Table/VirtualizedTableContainer.js +6 -2
  109. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  110. package/dist/Table/hooks/useFuzzySearch.d.ts +14 -0
  111. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
  112. package/dist/Table/hooks/useFuzzySearch.js +62 -0
  113. package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
  114. package/dist/Table/model/table-model.d.ts +78 -4
  115. package/dist/Table/model/table-model.d.ts.map +1 -1
  116. package/dist/Table/model/table-model.js +37 -19
  117. package/dist/Table/model/table-model.js.map +1 -1
  118. package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
  119. package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
  120. package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
  121. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  122. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
  123. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  124. package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
  125. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  126. package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
  127. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  128. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
  129. package/dist/TimeRangeSelector/TimeRangeSelector.js +25 -2
  130. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  131. package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
  132. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  133. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
  134. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  135. package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
  136. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  137. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -2
  138. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  139. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +1 -1
  140. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
  142. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  143. package/dist/TimeSeriesTooltip/TooltipHeader.js +1 -1
  144. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  145. package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
  146. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  147. package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
  148. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  149. package/dist/TimeZoneSelector.js +1 -1
  150. package/dist/TimeZoneSelector.js.map +1 -1
  151. package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
  152. package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  153. package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
  154. package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
  155. package/dist/TransformsEditor/TransformEditor.js +1 -1
  156. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  157. package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
  158. package/dist/TransformsEditor/TransformEditorContainer.js +2 -2
  159. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  160. package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
  161. package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
  162. package/dist/TransformsEditor/TransformsEditor.js +1 -1
  163. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  164. package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +1 -1
  165. package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
  166. package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
  167. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  168. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +1 -1
  169. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
  170. package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
  171. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  172. package/dist/YAxisLabel.js +1 -1
  173. package/dist/YAxisLabel.js.map +1 -1
  174. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
  175. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
  176. package/dist/cjs/FormatControls/FormatControls.js +4 -4
  177. package/dist/cjs/FormatControls/UnitSelector.js +3 -3
  178. package/dist/cjs/Legend/Legend.js +2 -2
  179. package/dist/cjs/Legend/TableLegend.js +16 -2
  180. package/dist/cjs/Table/Table.js +44 -11
  181. package/dist/cjs/Table/TableHeaderCell.js +54 -22
  182. package/dist/cjs/Table/TableToolbar.js +151 -0
  183. package/dist/cjs/Table/VirtualizedTable.js +155 -121
  184. package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
  185. package/dist/cjs/Table/hooks/useFuzzySearch.js +67 -0
  186. package/dist/cjs/Table/model/table-model.js +43 -19
  187. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +23 -0
  188. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
  189. package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
  190. package/dist/cjs/model/action.js +43 -0
  191. package/dist/cjs/model/bits.js +113 -0
  192. package/dist/cjs/model/bytes.js +115 -0
  193. package/dist/cjs/model/constants.js +23 -0
  194. package/dist/cjs/model/currency.js +126 -0
  195. package/dist/cjs/model/date.js +297 -0
  196. package/dist/cjs/model/decimal.js +72 -0
  197. package/dist/cjs/model/formatterCache.js +120 -0
  198. package/dist/cjs/model/index.js +17 -0
  199. package/dist/cjs/model/legend.js +101 -0
  200. package/dist/cjs/model/percent.js +82 -0
  201. package/dist/cjs/model/temperature.js +72 -0
  202. package/dist/cjs/model/thresholds.js +16 -0
  203. package/dist/cjs/model/throughput.js +161 -0
  204. package/dist/cjs/model/time.js +178 -0
  205. package/dist/cjs/model/transforms.js +29 -0
  206. package/dist/cjs/model/types.js +16 -0
  207. package/dist/cjs/model/units.js +186 -0
  208. package/dist/cjs/model/utils.js +48 -0
  209. package/dist/cjs/model/value-mapping.js +16 -0
  210. package/dist/cjs/theme/typography.js +1 -1
  211. package/dist/cjs/utils/axis.js +5 -5
  212. package/dist/cjs/utils/format.js +20 -0
  213. package/dist/cjs/utils/index.js +1 -0
  214. package/dist/cjs/utils/request-interpolation.js +49 -0
  215. package/dist/context/ChartsProvider.js +1 -1
  216. package/dist/context/ChartsProvider.js.map +1 -1
  217. package/dist/context/ItemActionsProvider.js +1 -1
  218. package/dist/context/ItemActionsProvider.js.map +1 -1
  219. package/dist/context/SelectionProvider.js +1 -1
  220. package/dist/context/SelectionProvider.js.map +1 -1
  221. package/dist/context/SnackbarProvider.js +1 -1
  222. package/dist/context/SnackbarProvider.js.map +1 -1
  223. package/dist/context/TimeZoneProvider.js +1 -1
  224. package/dist/context/TimeZoneProvider.js.map +1 -1
  225. package/dist/controls/TextField.js +1 -1
  226. package/dist/controls/TextField.js.map +1 -1
  227. package/dist/model/action.d.ts +4 -0
  228. package/dist/model/action.d.ts.map +1 -0
  229. package/dist/model/action.js +27 -0
  230. package/dist/model/action.js.map +1 -0
  231. package/dist/model/bits.d.ts +12 -0
  232. package/dist/model/bits.d.ts.map +1 -0
  233. package/dist/model/bits.js +89 -0
  234. package/dist/model/bits.js.map +1 -0
  235. package/dist/model/bytes.d.ts +12 -0
  236. package/dist/model/bytes.d.ts.map +1 -0
  237. package/dist/model/bytes.js +91 -0
  238. package/dist/model/bytes.js.map +1 -0
  239. package/dist/model/constants.d.ts +2 -0
  240. package/dist/model/constants.d.ts.map +1 -0
  241. package/dist/model/constants.js +15 -0
  242. package/dist/model/constants.js.map +1 -0
  243. package/dist/model/currency.d.ts +11 -0
  244. package/dist/model/currency.d.ts.map +1 -0
  245. package/dist/model/currency.js +107 -0
  246. package/dist/model/currency.js.map +1 -0
  247. package/dist/model/date.d.ts +28 -0
  248. package/dist/model/date.d.ts.map +1 -0
  249. package/dist/model/date.js +278 -0
  250. package/dist/model/date.js.map +1 -0
  251. package/dist/model/decimal.d.ts +12 -0
  252. package/dist/model/decimal.d.ts.map +1 -0
  253. package/dist/model/decimal.js +53 -0
  254. package/dist/model/decimal.js.map +1 -0
  255. package/dist/model/formatterCache.d.ts +11 -0
  256. package/dist/model/formatterCache.d.ts.map +1 -0
  257. package/dist/model/formatterCache.js +104 -0
  258. package/dist/model/formatterCache.js.map +1 -0
  259. package/dist/model/index.d.ts +17 -0
  260. package/dist/model/index.d.ts.map +1 -1
  261. package/dist/model/index.js +17 -0
  262. package/dist/model/index.js.map +1 -1
  263. package/dist/model/legend.d.ts +19 -0
  264. package/dist/model/legend.d.ts.map +1 -0
  265. package/dist/model/legend.js +61 -0
  266. package/dist/model/legend.js.map +1 -0
  267. package/dist/model/percent.d.ts +11 -0
  268. package/dist/model/percent.d.ts.map +1 -0
  269. package/dist/model/percent.js +63 -0
  270. package/dist/model/percent.js.map +1 -0
  271. package/dist/model/temperature.d.ts +11 -0
  272. package/dist/model/temperature.d.ts.map +1 -0
  273. package/dist/model/temperature.js +53 -0
  274. package/dist/model/temperature.js.map +1 -0
  275. package/dist/model/theme.d.ts +1 -1
  276. package/dist/model/theme.d.ts.map +1 -1
  277. package/dist/model/theme.js.map +1 -1
  278. package/dist/model/thresholds.d.ts +16 -0
  279. package/dist/model/thresholds.d.ts.map +1 -0
  280. package/dist/model/thresholds.js +15 -0
  281. package/dist/model/thresholds.js.map +1 -0
  282. package/dist/model/throughput.d.ts +12 -0
  283. package/dist/model/throughput.d.ts.map +1 -0
  284. package/dist/model/throughput.js +142 -0
  285. package/dist/model/throughput.js.map +1 -0
  286. package/dist/model/time.d.ts +23 -0
  287. package/dist/model/time.d.ts.map +1 -0
  288. package/dist/model/time.js +158 -0
  289. package/dist/model/time.js.map +1 -0
  290. package/dist/model/transforms.d.ts +43 -0
  291. package/dist/model/transforms.d.ts.map +1 -0
  292. package/dist/model/transforms.js +22 -0
  293. package/dist/model/transforms.js.map +1 -0
  294. package/dist/model/types.d.ts +56 -0
  295. package/dist/model/types.d.ts.map +1 -0
  296. package/dist/model/types.js +15 -0
  297. package/dist/model/types.js.map +1 -0
  298. package/dist/model/units.d.ts +105 -0
  299. package/dist/model/units.d.ts.map +1 -0
  300. package/dist/model/units.js +132 -0
  301. package/dist/model/units.js.map +1 -0
  302. package/dist/model/utils.d.ts +4 -0
  303. package/dist/model/utils.d.ts.map +1 -0
  304. package/dist/model/utils.js +32 -0
  305. package/dist/model/utils.js.map +1 -0
  306. package/dist/model/value-mapping.d.ts +35 -0
  307. package/dist/model/value-mapping.d.ts.map +1 -0
  308. package/dist/model/value-mapping.js +15 -0
  309. package/dist/model/value-mapping.js.map +1 -0
  310. package/dist/test/render.js +1 -1
  311. package/dist/test/render.js.map +1 -1
  312. package/dist/theme/typography.js +1 -1
  313. package/dist/theme/typography.js.map +1 -1
  314. package/dist/utils/axis.d.ts +1 -1
  315. package/dist/utils/axis.d.ts.map +1 -1
  316. package/dist/utils/axis.js +1 -1
  317. package/dist/utils/axis.js.map +1 -1
  318. package/dist/utils/format.d.ts +1 -0
  319. package/dist/utils/format.d.ts.map +1 -1
  320. package/dist/utils/format.js +17 -0
  321. package/dist/utils/format.js.map +1 -1
  322. package/dist/utils/index.d.ts +1 -0
  323. package/dist/utils/index.d.ts.map +1 -1
  324. package/dist/utils/index.js +1 -0
  325. package/dist/utils/index.js.map +1 -1
  326. package/dist/utils/request-interpolation.d.ts +6 -0
  327. package/dist/utils/request-interpolation.d.ts.map +1 -0
  328. package/dist/utils/request-interpolation.js +33 -0
  329. package/dist/utils/request-interpolation.js.map +1 -0
  330. package/package.json +4 -2
@@ -0,0 +1,132 @@
1
+ // Copyright 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 { formatBytes, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from './bytes';
14
+ import { formatBits, BITS_GROUP_CONFIG, BITS_UNIT_CONFIG } from './bits';
15
+ import { formatDecimal, DECIMAL_GROUP_CONFIG, DECIMAL_UNIT_CONFIG } from './decimal';
16
+ import { formatPercent, PERCENT_GROUP_CONFIG, PERCENT_UNIT_CONFIG } from './percent';
17
+ import { TEMPERATURE_GROUP_CONFIG, formatTemperature, TEMPERATURE_UNIT_CONFIG } from './temperature';
18
+ import { formatTime, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';
19
+ import { formatThroughput, THROUGHPUT_GROUP_CONFIG, THROUGHPUT_UNIT_CONFIG } from './throughput';
20
+ import { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG } from './currency';
21
+ import { formatDate, DATE_GROUP_CONFIG, DATE_UNIT_CONFIG } from './date';
22
+ /**
23
+ * Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.
24
+ * Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.
25
+ *
26
+ * To format bytes, we also make use of the `numbro` package,
27
+ * because it can handle adding units like KB, MB, GB, etc. correctly.
28
+ */ export const UNIT_GROUP_CONFIG = {
29
+ Time: TIME_GROUP_CONFIG,
30
+ Percent: PERCENT_GROUP_CONFIG,
31
+ Decimal: DECIMAL_GROUP_CONFIG,
32
+ Bytes: BYTES_GROUP_CONFIG,
33
+ Bits: BITS_GROUP_CONFIG,
34
+ Throughput: THROUGHPUT_GROUP_CONFIG,
35
+ Currency: CURRENCY_GROUP_CONFIG,
36
+ Temperature: TEMPERATURE_GROUP_CONFIG,
37
+ Date: DATE_GROUP_CONFIG
38
+ };
39
+ export const UNIT_CONFIG = {
40
+ ...TIME_UNIT_CONFIG,
41
+ ...PERCENT_UNIT_CONFIG,
42
+ ...DECIMAL_UNIT_CONFIG,
43
+ ...BYTES_UNIT_CONFIG,
44
+ ...BITS_UNIT_CONFIG,
45
+ ...THROUGHPUT_UNIT_CONFIG,
46
+ ...CURRENCY_UNIT_CONFIG,
47
+ ...TEMPERATURE_UNIT_CONFIG,
48
+ ...DATE_UNIT_CONFIG
49
+ };
50
+ export function formatValue(value, formatOptions) {
51
+ if (!formatOptions) {
52
+ return value.toString();
53
+ }
54
+ if (isBytesUnit(formatOptions)) {
55
+ return formatBytes(value, formatOptions);
56
+ }
57
+ if (isBitsUnit(formatOptions)) {
58
+ return formatBits(value, formatOptions);
59
+ }
60
+ if (isDecimalUnit(formatOptions)) {
61
+ return formatDecimal(value, formatOptions);
62
+ }
63
+ if (isPercentUnit(formatOptions)) {
64
+ return formatPercent(value, formatOptions);
65
+ }
66
+ if (isTimeUnit(formatOptions)) {
67
+ return formatTime(value, formatOptions);
68
+ }
69
+ if (isThroughputUnit(formatOptions)) {
70
+ return formatThroughput(value, formatOptions);
71
+ }
72
+ if (isCurrencyUnit(formatOptions)) {
73
+ return formatCurrency(value, formatOptions);
74
+ }
75
+ if (isDateUnit(formatOptions)) {
76
+ return formatDate(value, formatOptions);
77
+ }
78
+ if (isTemperatureUnit(formatOptions)) {
79
+ return formatTemperature(value, formatOptions);
80
+ }
81
+ const exhaustive = formatOptions;
82
+ throw new Error(`Unknown unit options ${exhaustive}`);
83
+ }
84
+ export function getUnitConfig(formatOptions) {
85
+ const unit = formatOptions.unit ?? 'decimal';
86
+ return UNIT_CONFIG[unit];
87
+ }
88
+ export function getUnitGroup(formatOptions) {
89
+ return getUnitConfig(formatOptions).group ?? 'Decimal';
90
+ }
91
+ export function getUnitGroupConfig(formatOptions) {
92
+ const unitConfig = getUnitConfig(formatOptions);
93
+ return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];
94
+ }
95
+ // Type guards
96
+ export function isTimeUnit(formatOptions) {
97
+ return getUnitGroup(formatOptions) === 'Time';
98
+ }
99
+ export function isPercentUnit(formatOptions) {
100
+ return getUnitGroup(formatOptions) === 'Percent';
101
+ }
102
+ export function isDecimalUnit(formatOptions) {
103
+ return getUnitGroup(formatOptions) === 'Decimal';
104
+ }
105
+ export function isBytesUnit(formatOptions) {
106
+ return getUnitGroup(formatOptions) === 'Bytes';
107
+ }
108
+ export function isBitsUnit(formatOptions) {
109
+ return getUnitGroup(formatOptions) === 'Bits';
110
+ }
111
+ export function isUnitWithDecimalPlaces(formatOptions) {
112
+ const groupConfig = getUnitGroupConfig(formatOptions);
113
+ return !!groupConfig.decimalPlaces;
114
+ }
115
+ export function isUnitWithShortValues(formatOptions) {
116
+ const groupConfig = getUnitGroupConfig(formatOptions);
117
+ return !!groupConfig.shortValues;
118
+ }
119
+ export function isThroughputUnit(formatOptions) {
120
+ return getUnitGroup(formatOptions) === 'Throughput';
121
+ }
122
+ export function isCurrencyUnit(formatOptions) {
123
+ return getUnitGroup(formatOptions) === 'Currency';
124
+ }
125
+ export function isDateUnit(formatOptions) {
126
+ return getUnitGroup(formatOptions) === 'Date';
127
+ }
128
+ export function isTemperatureUnit(formatOptions) {
129
+ return getUnitGroup(formatOptions) === 'Temperature';
130
+ }
131
+
132
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/units.ts"],"sourcesContent":["// Copyright 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 { formatBytes, BytesFormatOptions as BytesFormatOptions, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from './bytes';\nimport { formatBits, BitsFormatOptions as BitsFormatOptions, BITS_GROUP_CONFIG, BITS_UNIT_CONFIG } from './bits';\nimport {\n formatDecimal,\n DecimalFormatOptions as DecimalFormatOptions,\n DECIMAL_GROUP_CONFIG,\n DECIMAL_UNIT_CONFIG,\n} from './decimal';\nimport {\n formatPercent,\n PercentFormatOptions as PercentFormatOptions,\n PERCENT_GROUP_CONFIG,\n PERCENT_UNIT_CONFIG,\n} from './percent';\nimport {\n TEMPERATURE_GROUP_CONFIG,\n formatTemperature,\n TEMPERATURE_UNIT_CONFIG,\n TemperatureFormatOptions,\n} from './temperature';\nimport { formatTime, TimeFormatOptions as TimeFormatOptions, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';\nimport { UnitGroup, UnitGroupConfig, UnitConfig } from './types';\nimport {\n formatThroughput,\n THROUGHPUT_GROUP_CONFIG,\n THROUGHPUT_UNIT_CONFIG,\n ThroughputFormatOptions,\n} from './throughput';\nimport { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG, CurrencyFormatOptions } from './currency';\nimport { formatDate, DateFormatOptions, DATE_GROUP_CONFIG, DATE_UNIT_CONFIG } from './date';\n\n/**\n * Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.\n * Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.\n *\n * To format bytes, we also make use of the `numbro` package,\n * because it can handle adding units like KB, MB, GB, etc. correctly.\n */\n\nexport const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>> = {\n Time: TIME_GROUP_CONFIG,\n Percent: PERCENT_GROUP_CONFIG,\n Decimal: DECIMAL_GROUP_CONFIG,\n Bytes: BYTES_GROUP_CONFIG,\n Bits: BITS_GROUP_CONFIG,\n Throughput: THROUGHPUT_GROUP_CONFIG,\n Currency: CURRENCY_GROUP_CONFIG,\n Temperature: TEMPERATURE_GROUP_CONFIG,\n Date: DATE_GROUP_CONFIG,\n};\nexport const UNIT_CONFIG = {\n ...TIME_UNIT_CONFIG,\n ...PERCENT_UNIT_CONFIG,\n ...DECIMAL_UNIT_CONFIG,\n ...BYTES_UNIT_CONFIG,\n ...BITS_UNIT_CONFIG,\n ...THROUGHPUT_UNIT_CONFIG,\n ...CURRENCY_UNIT_CONFIG,\n ...TEMPERATURE_UNIT_CONFIG,\n ...DATE_UNIT_CONFIG,\n} as const;\n\nexport type FormatOptions =\n | TimeFormatOptions\n | PercentFormatOptions\n | DecimalFormatOptions\n | BytesFormatOptions\n | BitsFormatOptions\n | ThroughputFormatOptions\n | CurrencyFormatOptions\n | TemperatureFormatOptions\n | DateFormatOptions;\n\ntype HasDecimalPlaces<UnitOpt> = UnitOpt extends { decimalPlaces?: number } ? UnitOpt : never;\ntype HasShortValues<UnitOpt> = UnitOpt extends { shortValues?: boolean } ? UnitOpt : never;\n\nexport function formatValue(value: number, formatOptions?: FormatOptions): string {\n if (!formatOptions) {\n return value.toString();\n }\n\n if (isBytesUnit(formatOptions)) {\n return formatBytes(value, formatOptions);\n }\n\n if (isBitsUnit(formatOptions)) {\n return formatBits(value, formatOptions);\n }\n\n if (isDecimalUnit(formatOptions)) {\n return formatDecimal(value, formatOptions);\n }\n\n if (isPercentUnit(formatOptions)) {\n return formatPercent(value, formatOptions);\n }\n\n if (isTimeUnit(formatOptions)) {\n return formatTime(value, formatOptions);\n }\n\n if (isThroughputUnit(formatOptions)) {\n return formatThroughput(value, formatOptions);\n }\n\n if (isCurrencyUnit(formatOptions)) {\n return formatCurrency(value, formatOptions);\n }\n\n if (isDateUnit(formatOptions)) {\n return formatDate(value, formatOptions);\n }\n\n if (isTemperatureUnit(formatOptions)) {\n return formatTemperature(value, formatOptions);\n }\n\n const exhaustive: never = formatOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\nexport function getUnitConfig(formatOptions: FormatOptions): UnitConfig {\n const unit = formatOptions.unit ?? 'decimal';\n return UNIT_CONFIG[unit];\n}\n\nexport function getUnitGroup(formatOptions: FormatOptions): UnitGroup {\n return getUnitConfig(formatOptions).group ?? 'Decimal';\n}\n\nexport function getUnitGroupConfig(formatOptions: FormatOptions): UnitGroupConfig {\n const unitConfig = getUnitConfig(formatOptions);\n return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];\n}\n\n// Type guards\nexport function isTimeUnit(formatOptions: FormatOptions): formatOptions is TimeFormatOptions {\n return getUnitGroup(formatOptions) === 'Time';\n}\n\nexport function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions {\n return getUnitGroup(formatOptions) === 'Percent';\n}\n\nexport function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions {\n return getUnitGroup(formatOptions) === 'Decimal';\n}\n\nexport function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions {\n return getUnitGroup(formatOptions) === 'Bytes';\n}\n\nexport function isBitsUnit(formatOptions: FormatOptions): formatOptions is BitsFormatOptions {\n return getUnitGroup(formatOptions) === 'Bits';\n}\n\nexport function isUnitWithDecimalPlaces(\n formatOptions: FormatOptions\n): formatOptions is HasDecimalPlaces<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.decimalPlaces;\n}\n\nexport function isUnitWithShortValues(formatOptions: FormatOptions): formatOptions is HasShortValues<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.shortValues;\n}\n\nexport function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions {\n return getUnitGroup(formatOptions) === 'Throughput';\n}\n\nexport function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions {\n return getUnitGroup(formatOptions) === 'Currency';\n}\n\nexport function isDateUnit(formatOptions: FormatOptions): formatOptions is DateFormatOptions {\n return getUnitGroup(formatOptions) === 'Date';\n}\n\nexport function isTemperatureUnit(formatOptions: FormatOptions): formatOptions is TemperatureFormatOptions {\n return getUnitGroup(formatOptions) === 'Temperature';\n}\n"],"names":["formatBytes","BYTES_GROUP_CONFIG","BYTES_UNIT_CONFIG","formatBits","BITS_GROUP_CONFIG","BITS_UNIT_CONFIG","formatDecimal","DECIMAL_GROUP_CONFIG","DECIMAL_UNIT_CONFIG","formatPercent","PERCENT_GROUP_CONFIG","PERCENT_UNIT_CONFIG","TEMPERATURE_GROUP_CONFIG","formatTemperature","TEMPERATURE_UNIT_CONFIG","formatTime","TIME_GROUP_CONFIG","TIME_UNIT_CONFIG","formatThroughput","THROUGHPUT_GROUP_CONFIG","THROUGHPUT_UNIT_CONFIG","formatCurrency","CURRENCY_GROUP_CONFIG","CURRENCY_UNIT_CONFIG","formatDate","DATE_GROUP_CONFIG","DATE_UNIT_CONFIG","UNIT_GROUP_CONFIG","Time","Percent","Decimal","Bytes","Bits","Throughput","Currency","Temperature","Date","UNIT_CONFIG","formatValue","value","formatOptions","toString","isBytesUnit","isBitsUnit","isDecimalUnit","isPercentUnit","isTimeUnit","isThroughputUnit","isCurrencyUnit","isDateUnit","isTemperatureUnit","exhaustive","Error","getUnitConfig","unit","getUnitGroup","group","getUnitGroupConfig","unitConfig","isUnitWithDecimalPlaces","groupConfig","decimalPlaces","isUnitWithShortValues","shortValues"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAA4CC,kBAAkB,EAAEC,iBAAiB,QAAQ,UAAU;AACvH,SAASC,UAAU,EAA0CC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AACjH,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,wBAAwB,EACxBC,iBAAiB,EACjBC,uBAAuB,QAElB,gBAAgB;AACvB,SAASC,UAAU,EAA0CC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AAEjH,SACEC,gBAAgB,EAChBC,uBAAuB,EACvBC,sBAAsB,QAEjB,eAAe;AACtB,SAASC,cAAc,EAAEC,qBAAqB,EAAEC,oBAAoB,QAA+B,aAAa;AAChH,SAASC,UAAU,EAAqBC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AAE5F;;;;;;CAMC,GAED,OAAO,MAAMC,oBAAkE;IAC7EC,MAAMZ;IACNa,SAASnB;IACToB,SAASvB;IACTwB,OAAO9B;IACP+B,MAAM5B;IACN6B,YAAYd;IACZe,UAAUZ;IACVa,aAAavB;IACbwB,MAAMX;AACR,EAAE;AACF,OAAO,MAAMY,cAAc;IACzB,GAAGpB,gBAAgB;IACnB,GAAGN,mBAAmB;IACtB,GAAGH,mBAAmB;IACtB,GAAGN,iBAAiB;IACpB,GAAGG,gBAAgB;IACnB,GAAGe,sBAAsB;IACzB,GAAGG,oBAAoB;IACvB,GAAGT,uBAAuB;IAC1B,GAAGY,gBAAgB;AACrB,EAAW;AAgBX,OAAO,SAASY,YAAYC,KAAa,EAAEC,aAA6B;IACtE,IAAI,CAACA,eAAe;QAClB,OAAOD,MAAME,QAAQ;IACvB;IAEA,IAAIC,YAAYF,gBAAgB;QAC9B,OAAOxC,YAAYuC,OAAOC;IAC5B;IAEA,IAAIG,WAAWH,gBAAgB;QAC7B,OAAOrC,WAAWoC,OAAOC;IAC3B;IAEA,IAAII,cAAcJ,gBAAgB;QAChC,OAAOlC,cAAciC,OAAOC;IAC9B;IAEA,IAAIK,cAAcL,gBAAgB;QAChC,OAAO/B,cAAc8B,OAAOC;IAC9B;IAEA,IAAIM,WAAWN,gBAAgB;QAC7B,OAAOzB,WAAWwB,OAAOC;IAC3B;IAEA,IAAIO,iBAAiBP,gBAAgB;QACnC,OAAOtB,iBAAiBqB,OAAOC;IACjC;IAEA,IAAIQ,eAAeR,gBAAgB;QACjC,OAAOnB,eAAekB,OAAOC;IAC/B;IAEA,IAAIS,WAAWT,gBAAgB;QAC7B,OAAOhB,WAAWe,OAAOC;IAC3B;IAEA,IAAIU,kBAAkBV,gBAAgB;QACpC,OAAO3B,kBAAkB0B,OAAOC;IAClC;IAEA,MAAMW,aAAoBX;IAC1B,MAAM,IAAIY,MAAM,CAAC,qBAAqB,EAAED,YAAY;AACtD;AAEA,OAAO,SAASE,cAAcb,aAA4B;IACxD,MAAMc,OAAOd,cAAcc,IAAI,IAAI;IACnC,OAAOjB,WAAW,CAACiB,KAAK;AAC1B;AAEA,OAAO,SAASC,aAAaf,aAA4B;IACvD,OAAOa,cAAcb,eAAegB,KAAK,IAAI;AAC/C;AAEA,OAAO,SAASC,mBAAmBjB,aAA4B;IAC7D,MAAMkB,aAAaL,cAAcb;IACjC,OAAOb,iBAAiB,CAAC+B,WAAWF,KAAK,IAAI,UAAU;AACzD;AAEA,cAAc;AACd,OAAO,SAASV,WAAWN,aAA4B;IACrD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASK,cAAcL,aAA4B;IACxD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASI,cAAcJ,aAA4B;IACxD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASE,YAAYF,aAA4B;IACtD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASG,WAAWH,aAA4B;IACrD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASmB,wBACdnB,aAA4B;IAE5B,MAAMoB,cAAcH,mBAAmBjB;IAEvC,OAAO,CAAC,CAACoB,YAAYC,aAAa;AACpC;AAEA,OAAO,SAASC,sBAAsBtB,aAA4B;IAChE,MAAMoB,cAAcH,mBAAmBjB;IAEvC,OAAO,CAAC,CAACoB,YAAYG,WAAW;AAClC;AAEA,OAAO,SAAShB,iBAAiBP,aAA4B;IAC3D,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASQ,eAAeR,aAA4B;IACzD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASS,WAAWT,aAA4B;IACrD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASU,kBAAkBV,aAA4B;IAC5D,OAAOe,aAAaf,mBAAmB;AACzC"}
@@ -0,0 +1,4 @@
1
+ export declare function shouldShortenValues(shortValues?: boolean): boolean;
2
+ export declare function hasDecimalPlaces(decimalPlaces?: number): boolean;
3
+ export declare function limitDecimalPlaces(num?: number): number | undefined;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/model/utils.ts"],"names":[],"mappings":"AAaA,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAElE;AAED,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhE;AAKD,wBAAgB,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUnE"}
@@ -0,0 +1,32 @@
1
+ // Copyright 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
+ export function shouldShortenValues(shortValues) {
14
+ return shortValues !== false;
15
+ }
16
+ export function hasDecimalPlaces(decimalPlaces) {
17
+ return typeof decimalPlaces === 'number';
18
+ }
19
+ // Avoids maximumFractionDigits out-of-range error.
20
+ // Allowed values are 0 to 20.
21
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits
22
+ export function limitDecimalPlaces(num) {
23
+ if (!num) return num;
24
+ if (num < 0) {
25
+ num = 0;
26
+ } else if (num > 20) {
27
+ num = 20;
28
+ }
29
+ return num;
30
+ }
31
+
32
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/utils.ts"],"sourcesContent":["// Copyright 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 function shouldShortenValues(shortValues?: boolean): boolean {\n return shortValues !== false;\n}\n\nexport function hasDecimalPlaces(decimalPlaces?: number): boolean {\n return typeof decimalPlaces === 'number';\n}\n\n// Avoids maximumFractionDigits out-of-range error.\n// Allowed values are 0 to 20.\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits\nexport function limitDecimalPlaces(num?: number): number | undefined {\n if (!num) return num;\n\n if (num < 0) {\n num = 0;\n } else if (num > 20) {\n num = 20;\n }\n\n return num;\n}\n"],"names":["shouldShortenValues","shortValues","hasDecimalPlaces","decimalPlaces","limitDecimalPlaces","num"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,SAASA,oBAAoBC,WAAqB;IACvD,OAAOA,gBAAgB;AACzB;AAEA,OAAO,SAASC,iBAAiBC,aAAsB;IACrD,OAAO,OAAOA,kBAAkB;AAClC;AAEA,mDAAmD;AACnD,8BAA8B;AAC9B,wIAAwI;AACxI,OAAO,SAASC,mBAAmBC,GAAY;IAC7C,IAAI,CAACA,KAAK,OAAOA;IAEjB,IAAIA,MAAM,GAAG;QACXA,MAAM;IACR,OAAO,IAAIA,MAAM,IAAI;QACnBA,MAAM;IACR;IAEA,OAAOA;AACT"}
@@ -0,0 +1,35 @@
1
+ export type ValueMapping = ValueMappingOptions | ValueMappingOptionsRange | ValueMappingOptionsRegex | ValueMappingOptionsMisc;
2
+ export interface ValueMappingOptions {
3
+ kind: 'Value';
4
+ spec: {
5
+ value: string | number;
6
+ result: MappedValue;
7
+ };
8
+ }
9
+ export interface ValueMappingOptionsRange {
10
+ kind: 'Range';
11
+ spec: {
12
+ from?: number;
13
+ to?: number;
14
+ result: MappedValue;
15
+ };
16
+ }
17
+ export interface ValueMappingOptionsRegex {
18
+ kind: 'Regex';
19
+ spec: {
20
+ pattern: string;
21
+ result: MappedValue;
22
+ };
23
+ }
24
+ export interface ValueMappingOptionsMisc {
25
+ kind: 'Misc';
26
+ spec: {
27
+ value: 'empty' | 'null' | 'NaN' | 'true' | 'false';
28
+ result: MappedValue;
29
+ };
30
+ }
31
+ export interface MappedValue {
32
+ value: number | string;
33
+ color?: string;
34
+ }
35
+ //# sourceMappingURL=value-mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-mapping.d.ts","sourceRoot":"","sources":["../../src/model/value-mapping.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,YAAY,GACpB,mBAAmB,GACnB,wBAAwB,GACxB,wBAAwB,GACxB,uBAAuB,CAAC;AAE5B,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;QACnD,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,15 @@
1
+ // Copyright 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
+ export { };
14
+
15
+ //# sourceMappingURL=value-mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/value-mapping.ts"],"sourcesContent":["// Copyright 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 type ValueMapping =\n | ValueMappingOptions\n | ValueMappingOptionsRange\n | ValueMappingOptionsRegex\n | ValueMappingOptionsMisc;\n\nexport interface ValueMappingOptions {\n kind: 'Value';\n spec: {\n value: string | number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRange {\n kind: 'Range';\n spec: {\n from?: number;\n to?: number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRegex {\n kind: 'Regex';\n spec: {\n pattern: string;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsMisc {\n kind: 'Misc';\n spec: {\n value: 'empty' | 'null' | 'NaN' | 'true' | 'false';\n result: MappedValue;\n };\n}\n\nexport interface MappedValue {\n value: number | string;\n color?: string;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyCjC,WAGC"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { render } from '@testing-library/react';
15
15
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
16
16
  const queryClient = new QueryClient({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 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, RenderOptions, RenderResult } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ReactElement } from 'react';\n\nconst queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } });\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult {\n return render(<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>, options);\n}\n"],"names":["render","QueryClient","QueryClientProvider","queryClient","defaultOptions","queries","refetchOnWindowFocus","renderWithContext","ui","options","client"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,MAAM,QAAqC,yBAAyB;AAC7E,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,wBAAwB;AAGzE,MAAMC,cAAc,IAAIF,YAAY;IAAEG,gBAAgB;QAAEC,SAAS;YAAEC,sBAAsB;QAAM;IAAE;AAAE;AAEnG;;CAEC,GACD,OAAO,SAASC,kBAAkBC,EAAgB,EAAEC,OAAwC;IAC1F,OAAOT,qBAAO,KAACE;QAAoBQ,QAAQP;kBAAcK;QAA2BC;AACtF"}
1
+ {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 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, RenderOptions, RenderResult } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ReactElement } from 'react';\n\nconst queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } });\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult {\n return render(<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>, options);\n}\n"],"names":["render","QueryClient","QueryClientProvider","queryClient","defaultOptions","queries","refetchOnWindowFocus","renderWithContext","ui","options","client"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,QAAqC,yBAAyB;AAC7E,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,wBAAwB;AAGzE,MAAMC,cAAc,IAAIF,YAAY;IAAEG,gBAAgB;QAAEC,SAAS;YAAEC,sBAAsB;QAAM;IAAE;AAAE;AAEnG;;CAEC,GACD,OAAO,SAASC,kBAAkBC,EAAgB,EAAEC,OAAwC;IAC1F,OAAOT,qBAAO,KAACE;QAAoBQ,QAAQP;kBAAcK;QAA2BC;AACtF"}
@@ -20,7 +20,7 @@ import '@fontsource/inter/900.css';
20
20
  const fontWeightLight = 300;
21
21
  const fontWeightRegular = 400;
22
22
  const fontWeightMedium = 600;
23
- const fontWeightBold = 900;
23
+ const fontWeightBold = 700;
24
24
  /**
25
25
  * Theme typography options that are the same across both the dark and light themes.
26
26
  */ export const typography = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/typography.ts"],"sourcesContent":["// Copyright 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 '@fontsource/inter/300.css';\nimport '@fontsource/inter/400.css';\nimport '@fontsource/inter/500.css';\nimport '@fontsource/inter/600.css';\nimport '@fontsource/inter/700.css';\nimport '@fontsource/inter/900.css';\nimport { ThemeOptions } from '@mui/material';\n\n// Font weights need to correspond with the imports at the top of the file\nconst fontWeightLight = 300;\nconst fontWeightRegular = 400;\nconst fontWeightMedium = 600;\nconst fontWeightBold = 900;\n\n/**\n * Theme typography options that are the same across both the dark and light themes.\n */\nexport const typography: ThemeOptions['typography'] = {\n fontFamily:\n 'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"',\n\n fontWeightLight,\n fontWeightRegular,\n fontWeightMedium,\n fontWeightBold,\n\n h1: {\n fontSize: '1.5rem', // 24px\n fontWeight: fontWeightMedium,\n lineHeight: '32px',\n },\n h2: {\n fontSize: '1.25rem', // 20px\n fontWeight: fontWeightMedium,\n lineHeight: '28px',\n },\n h3: {\n fontSize: '1rem', // 16px\n fontWeight: fontWeightMedium,\n lineHeight: '24px',\n },\n h4: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightMedium,\n lineHeight: '22px',\n },\n h5: undefined,\n h6: undefined,\n\n body1: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightRegular,\n lineHeight: '20px',\n },\n body2: {\n fontSize: '0.75rem', // 12px\n fontWeight: fontWeightRegular,\n lineHeight: '18px',\n },\n subtitle1: {\n fontSize: '1rem', // 16px\n fontWeight: fontWeightRegular,\n lineHeight: '24px',\n letterSpacing: '0.02rem',\n },\n subtitle2: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightMedium,\n lineHeight: '22px',\n letterSpacing: '0.03rem',\n textTransform: 'uppercase',\n },\n\n button: {\n // 14px\n fontSize: '0.875rem',\n fontWeight: fontWeightMedium,\n // 20 px\n lineHeight: '1.25rem',\n textTransform: 'none',\n letterSpacing: '0.03rem',\n },\n caption: {\n fontSize: '0.6875rem', // 11px\n fontWeight: fontWeightRegular,\n lineHeight: '16px',\n },\n};\n"],"names":["fontWeightLight","fontWeightRegular","fontWeightMedium","fontWeightBold","typography","fontFamily","h1","fontSize","fontWeight","lineHeight","h2","h3","h4","h5","undefined","h6","body1","body2","subtitle1","letterSpacing","subtitle2","textTransform","button","caption"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AAGnC,0EAA0E;AAC1E,MAAMA,kBAAkB;AACxB,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AAEvB;;CAEC,GACD,OAAO,MAAMC,aAAyC;IACpDC,YACE;IAEFL;IACAC;IACAC;IACAC;IAEAG,IAAI;QACFC,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAC,IAAI;QACFH,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAE,IAAI;QACFJ,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAG,IAAI;QACFL,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAI,IAAIC;IACJC,IAAID;IAEJE,OAAO;QACLT,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;IACAQ,OAAO;QACLV,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;IACAS,WAAW;QACTX,UAAU;QACVC,YAAYP;QACZQ,YAAY;QACZU,eAAe;IACjB;IACAC,WAAW;QACTb,UAAU;QACVC,YAAYN;QACZO,YAAY;QACZU,eAAe;QACfE,eAAe;IACjB;IAEAC,QAAQ;QACN,OAAO;QACPf,UAAU;QACVC,YAAYN;QACZ,QAAQ;QACRO,YAAY;QACZY,eAAe;QACfF,eAAe;IACjB;IACAI,SAAS;QACPhB,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/theme/typography.ts"],"sourcesContent":["// Copyright 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 '@fontsource/inter/300.css';\nimport '@fontsource/inter/400.css';\nimport '@fontsource/inter/500.css';\nimport '@fontsource/inter/600.css';\nimport '@fontsource/inter/700.css';\nimport '@fontsource/inter/900.css';\nimport { ThemeOptions } from '@mui/material';\n\n// Font weights need to correspond with the imports at the top of the file\nconst fontWeightLight = 300;\nconst fontWeightRegular = 400;\nconst fontWeightMedium = 600;\nconst fontWeightBold = 700;\n\n/**\n * Theme typography options that are the same across both the dark and light themes.\n */\nexport const typography: ThemeOptions['typography'] = {\n fontFamily:\n 'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"',\n\n fontWeightLight,\n fontWeightRegular,\n fontWeightMedium,\n fontWeightBold,\n\n h1: {\n fontSize: '1.5rem', // 24px\n fontWeight: fontWeightMedium,\n lineHeight: '32px',\n },\n h2: {\n fontSize: '1.25rem', // 20px\n fontWeight: fontWeightMedium,\n lineHeight: '28px',\n },\n h3: {\n fontSize: '1rem', // 16px\n fontWeight: fontWeightMedium,\n lineHeight: '24px',\n },\n h4: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightMedium,\n lineHeight: '22px',\n },\n h5: undefined,\n h6: undefined,\n\n body1: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightRegular,\n lineHeight: '20px',\n },\n body2: {\n fontSize: '0.75rem', // 12px\n fontWeight: fontWeightRegular,\n lineHeight: '18px',\n },\n subtitle1: {\n fontSize: '1rem', // 16px\n fontWeight: fontWeightRegular,\n lineHeight: '24px',\n letterSpacing: '0.02rem',\n },\n subtitle2: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightMedium,\n lineHeight: '22px',\n letterSpacing: '0.03rem',\n textTransform: 'uppercase',\n },\n\n button: {\n // 14px\n fontSize: '0.875rem',\n fontWeight: fontWeightMedium,\n // 20 px\n lineHeight: '1.25rem',\n textTransform: 'none',\n letterSpacing: '0.03rem',\n },\n caption: {\n fontSize: '0.6875rem', // 11px\n fontWeight: fontWeightRegular,\n lineHeight: '16px',\n },\n};\n"],"names":["fontWeightLight","fontWeightRegular","fontWeightMedium","fontWeightBold","typography","fontFamily","h1","fontSize","fontWeight","lineHeight","h2","h3","h4","h5","undefined","h6","body1","body2","subtitle1","letterSpacing","subtitle2","textTransform","button","caption"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AAGnC,0EAA0E;AAC1E,MAAMA,kBAAkB;AACxB,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AAEvB;;CAEC,GACD,OAAO,MAAMC,aAAyC;IACpDC,YACE;IAEFL;IACAC;IACAC;IACAC;IAEAG,IAAI;QACFC,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAC,IAAI;QACFH,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAE,IAAI;QACFJ,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAG,IAAI;QACFL,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAI,IAAIC;IACJC,IAAID;IAEJE,OAAO;QACLT,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;IACAQ,OAAO;QACLV,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;IACAS,WAAW;QACTX,UAAU;QACVC,YAAYP;QACZQ,YAAY;QACZU,eAAe;IACjB;IACAC,WAAW;QACTb,UAAU;QACVC,YAAYN;QACZO,YAAY;QACZU,eAAe;QACfE,eAAe;IACjB;IAEAC,QAAQ;QACN,OAAO;QACPf,UAAU;QACVC,YAAYN;QACZ,QAAQ;QACRO,YAAY;QACZY,eAAe;QACfF,eAAe;IACjB;IACAI,SAAS;QACPhB,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;AACF,EAAE"}
@@ -1,5 +1,5 @@
1
1
  import type { XAXisComponentOption, YAXisComponentOption } from 'echarts';
2
- import { FormatOptions } from '@perses-dev/core';
2
+ import { FormatOptions } from '../model';
3
3
  export interface YAxisConfig {
4
4
  format?: FormatOptions;
5
5
  position?: 'left' | 'right';
@@ -1 +1 @@
1
- {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/utils/axis.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAe,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA0BD,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,EAAE,CAWpH;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,UAAU,EAAE,aAAa,GAAG,SAAS,EACrC,iBAAiB,EAAE,aAAa,EAAE,EAClC,SAAS,CAAC,EAAE,MAAM,EAAE,GACnB,oBAAoB,EAAE,CAkDxB"}
1
+ {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/utils/axis.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA0BD,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,EAAE,CAWpH;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,UAAU,EAAE,aAAa,GAAG,SAAS,EACrC,iBAAiB,EAAE,aAAa,EAAE,EAClC,SAAS,CAAC,EAAE,MAAM,EAAE,GACnB,oBAAoB,EAAE,CAkDxB"}
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import merge from 'lodash/merge';
14
- import { formatValue } from '@perses-dev/core'; // TODO
14
+ import { formatValue } from '../model';
15
15
  // Character width multipliers (approximate for typical UI fonts)
16
16
  const CHAR_WIDTH_BASE = 6;
17
17
  const AXIS_LABEL_PADDING = 10; // Extra padding to avoid label clipping
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/axis.ts"],"sourcesContent":["// Copyright 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 merge from 'lodash/merge';\nimport type { XAXisComponentOption, YAXisComponentOption } from 'echarts';\nimport { formatValue, FormatOptions } from '@perses-dev/core'; // TODO\n\nexport interface YAxisConfig {\n format?: FormatOptions;\n position?: 'left' | 'right';\n show?: boolean;\n min?: number;\n max?: number;\n}\n\n// Character width multipliers (approximate for typical UI fonts)\nconst CHAR_WIDTH_BASE = 6;\nconst AXIS_LABEL_PADDING = 10; // Extra padding to avoid label clipping\n\n/**\n * Estimate the pixel width needed for an axis label using Canvas API.\n */\nfunction estimateLabelWidth(format: FormatOptions | undefined, maxValue: number): number {\n const formattedLabel = formatValue(maxValue, format);\n // Create a canvas element (reuse if possible for performance)\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n if (!context) {\n // Fallback to estimation if canvas not available\n return formattedLabel.length * CHAR_WIDTH_BASE;\n }\n context.font = '12px sans-serif';\n const metrics = context.measureText(formattedLabel);\n return metrics.width;\n}\n\n/*\n * Populate yAxis or xAxis properties, returns an Array since multiple axes are supported\n */\nexport function getFormattedAxis(axis?: YAXisComponentOption | XAXisComponentOption, unit?: FormatOptions): unknown[] {\n const AXIS_DEFAULT = {\n type: 'value',\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number): string => {\n return formatValue(value, unit);\n },\n },\n };\n return [merge(AXIS_DEFAULT, axis)];\n}\n\n/**\n * Create multiple Y axes configurations for ECharts\n * The first axis (index 0) is always on the left side (default axis from panel settings)\n * Additional axes are placed on the right side\n *\n * @param baseAxis - Base axis configuration from panel settings\n * @param baseFormat - Format for the base/default Y axis\n * @param additionalFormats - Array of formats for additional right-side Y axes\n * @param maxValues - Optional array of max values for each additional format (used to compute dynamic label widths)\n */\nexport function getFormattedMultipleYAxes(\n baseAxis: YAXisComponentOption | undefined,\n baseFormat: FormatOptions | undefined,\n additionalFormats: FormatOptions[],\n maxValues?: number[]\n): YAXisComponentOption[] {\n const axes: YAXisComponentOption[] = [];\n\n // Base/default Y axis (left side)\n const baseAxisConfig: YAXisComponentOption = merge(\n {\n type: 'value',\n position: 'left',\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number): string => {\n return formatValue(value, baseFormat);\n },\n // Let ECharts handle width automatically\n overflow: 'truncate',\n },\n },\n baseAxis\n );\n axes.push(baseAxisConfig);\n\n // Calculate cumulative offsets based on actual formatted label widths\n let cumulativeOffset = 0;\n\n // Additional Y axes (right side) for each unique format\n additionalFormats.forEach((format, index) => {\n const rightAxisConfig: YAXisComponentOption = {\n type: 'value',\n position: 'right',\n // Dynamic offset based on cumulative width of preceding axis labels\n offset: cumulativeOffset,\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number): string => {\n return formatValue(value, format);\n },\n },\n splitLine: {\n show: false, // Hide grid lines for right-side axes to reduce visual noise\n },\n show: baseAxis?.show,\n };\n axes.push(rightAxisConfig);\n // For subsequent axes, add the width of the previous axis's labels\n if (maxValues) {\n cumulativeOffset += estimateLabelWidth(format, maxValues[index] ?? 1000) + AXIS_LABEL_PADDING;\n }\n });\n\n return axes;\n}\n"],"names":["merge","formatValue","CHAR_WIDTH_BASE","AXIS_LABEL_PADDING","estimateLabelWidth","format","maxValue","formattedLabel","canvas","document","createElement","context","getContext","length","font","metrics","measureText","width","getFormattedAxis","axis","unit","AXIS_DEFAULT","type","boundaryGap","axisLabel","formatter","value","getFormattedMultipleYAxes","baseAxis","baseFormat","additionalFormats","maxValues","axes","baseAxisConfig","position","overflow","push","cumulativeOffset","forEach","index","rightAxisConfig","offset","splitLine","show"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,WAAW,eAAe;AAEjC,SAASC,WAAW,QAAuB,mBAAmB,CAAC,OAAO;AAUtE,iEAAiE;AACjE,MAAMC,kBAAkB;AACxB,MAAMC,qBAAqB,IAAI,wCAAwC;AAEvE;;CAEC,GACD,SAASC,mBAAmBC,MAAiC,EAAEC,QAAgB;IAC7E,MAAMC,iBAAiBN,YAAYK,UAAUD;IAC7C,8DAA8D;IAC9D,MAAMG,SAASC,SAASC,aAAa,CAAC;IACtC,MAAMC,UAAUH,OAAOI,UAAU,CAAC;IAClC,IAAI,CAACD,SAAS;QACZ,iDAAiD;QACjD,OAAOJ,eAAeM,MAAM,GAAGX;IACjC;IACAS,QAAQG,IAAI,GAAG;IACf,MAAMC,UAAUJ,QAAQK,WAAW,CAACT;IACpC,OAAOQ,QAAQE,KAAK;AACtB;AAEA;;CAEC,GACD,OAAO,SAASC,iBAAiBC,IAAkD,EAAEC,IAAoB;IACvG,MAAMC,eAAe;QACnBC,MAAM;QACNC,aAAa;YAAC;YAAG;SAAM;QACvBC,WAAW;YACTC,WAAW,CAACC;gBACV,OAAOzB,YAAYyB,OAAON;YAC5B;QACF;IACF;IACA,OAAO;QAACpB,MAAMqB,cAAcF;KAAM;AACpC;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASQ,0BACdC,QAA0C,EAC1CC,UAAqC,EACrCC,iBAAkC,EAClCC,SAAoB;IAEpB,MAAMC,OAA+B,EAAE;IAEvC,kCAAkC;IAClC,MAAMC,iBAAuCjC,MAC3C;QACEsB,MAAM;QACNY,UAAU;QACVX,aAAa;YAAC;YAAG;SAAM;QACvBC,WAAW;YACTC,WAAW,CAACC;gBACV,OAAOzB,YAAYyB,OAAOG;YAC5B;YACA,yCAAyC;YACzCM,UAAU;QACZ;IACF,GACAP;IAEFI,KAAKI,IAAI,CAACH;IAEV,sEAAsE;IACtE,IAAII,mBAAmB;IAEvB,wDAAwD;IACxDP,kBAAkBQ,OAAO,CAAC,CAACjC,QAAQkC;QACjC,MAAMC,kBAAwC;YAC5ClB,MAAM;YACNY,UAAU;YACV,oEAAoE;YACpEO,QAAQJ;YACRd,aAAa;gBAAC;gBAAG;aAAM;YACvBC,WAAW;gBACTC,WAAW,CAACC;oBACV,OAAOzB,YAAYyB,OAAOrB;gBAC5B;YACF;YACAqC,WAAW;gBACTC,MAAM;YACR;YACAA,MAAMf,UAAUe;QAClB;QACAX,KAAKI,IAAI,CAACI;QACV,mEAAmE;QACnE,IAAIT,WAAW;YACbM,oBAAoBjC,mBAAmBC,QAAQ0B,SAAS,CAACQ,MAAM,IAAI,QAAQpC;QAC7E;IACF;IAEA,OAAO6B;AACT"}
1
+ {"version":3,"sources":["../../src/utils/axis.ts"],"sourcesContent":["// Copyright 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 merge from 'lodash/merge';\nimport type { XAXisComponentOption, YAXisComponentOption } from 'echarts';\nimport { FormatOptions, formatValue } from '../model';\n\nexport interface YAxisConfig {\n format?: FormatOptions;\n position?: 'left' | 'right';\n show?: boolean;\n min?: number;\n max?: number;\n}\n\n// Character width multipliers (approximate for typical UI fonts)\nconst CHAR_WIDTH_BASE = 6;\nconst AXIS_LABEL_PADDING = 10; // Extra padding to avoid label clipping\n\n/**\n * Estimate the pixel width needed for an axis label using Canvas API.\n */\nfunction estimateLabelWidth(format: FormatOptions | undefined, maxValue: number): number {\n const formattedLabel = formatValue(maxValue, format);\n // Create a canvas element (reuse if possible for performance)\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n if (!context) {\n // Fallback to estimation if canvas not available\n return formattedLabel.length * CHAR_WIDTH_BASE;\n }\n context.font = '12px sans-serif';\n const metrics = context.measureText(formattedLabel);\n return metrics.width;\n}\n\n/*\n * Populate yAxis or xAxis properties, returns an Array since multiple axes are supported\n */\nexport function getFormattedAxis(axis?: YAXisComponentOption | XAXisComponentOption, unit?: FormatOptions): unknown[] {\n const AXIS_DEFAULT = {\n type: 'value',\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number): string => {\n return formatValue(value, unit);\n },\n },\n };\n return [merge(AXIS_DEFAULT, axis)];\n}\n\n/**\n * Create multiple Y axes configurations for ECharts\n * The first axis (index 0) is always on the left side (default axis from panel settings)\n * Additional axes are placed on the right side\n *\n * @param baseAxis - Base axis configuration from panel settings\n * @param baseFormat - Format for the base/default Y axis\n * @param additionalFormats - Array of formats for additional right-side Y axes\n * @param maxValues - Optional array of max values for each additional format (used to compute dynamic label widths)\n */\nexport function getFormattedMultipleYAxes(\n baseAxis: YAXisComponentOption | undefined,\n baseFormat: FormatOptions | undefined,\n additionalFormats: FormatOptions[],\n maxValues?: number[]\n): YAXisComponentOption[] {\n const axes: YAXisComponentOption[] = [];\n\n // Base/default Y axis (left side)\n const baseAxisConfig: YAXisComponentOption = merge(\n {\n type: 'value',\n position: 'left',\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number): string => {\n return formatValue(value, baseFormat);\n },\n // Let ECharts handle width automatically\n overflow: 'truncate',\n },\n },\n baseAxis\n );\n axes.push(baseAxisConfig);\n\n // Calculate cumulative offsets based on actual formatted label widths\n let cumulativeOffset = 0;\n\n // Additional Y axes (right side) for each unique format\n additionalFormats.forEach((format, index) => {\n const rightAxisConfig: YAXisComponentOption = {\n type: 'value',\n position: 'right',\n // Dynamic offset based on cumulative width of preceding axis labels\n offset: cumulativeOffset,\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number): string => {\n return formatValue(value, format);\n },\n },\n splitLine: {\n show: false, // Hide grid lines for right-side axes to reduce visual noise\n },\n show: baseAxis?.show,\n };\n axes.push(rightAxisConfig);\n // For subsequent axes, add the width of the previous axis's labels\n if (maxValues) {\n cumulativeOffset += estimateLabelWidth(format, maxValues[index] ?? 1000) + AXIS_LABEL_PADDING;\n }\n });\n\n return axes;\n}\n"],"names":["merge","formatValue","CHAR_WIDTH_BASE","AXIS_LABEL_PADDING","estimateLabelWidth","format","maxValue","formattedLabel","canvas","document","createElement","context","getContext","length","font","metrics","measureText","width","getFormattedAxis","axis","unit","AXIS_DEFAULT","type","boundaryGap","axisLabel","formatter","value","getFormattedMultipleYAxes","baseAxis","baseFormat","additionalFormats","maxValues","axes","baseAxisConfig","position","overflow","push","cumulativeOffset","forEach","index","rightAxisConfig","offset","splitLine","show"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,WAAW,eAAe;AAEjC,SAAwBC,WAAW,QAAQ,WAAW;AAUtD,iEAAiE;AACjE,MAAMC,kBAAkB;AACxB,MAAMC,qBAAqB,IAAI,wCAAwC;AAEvE;;CAEC,GACD,SAASC,mBAAmBC,MAAiC,EAAEC,QAAgB;IAC7E,MAAMC,iBAAiBN,YAAYK,UAAUD;IAC7C,8DAA8D;IAC9D,MAAMG,SAASC,SAASC,aAAa,CAAC;IACtC,MAAMC,UAAUH,OAAOI,UAAU,CAAC;IAClC,IAAI,CAACD,SAAS;QACZ,iDAAiD;QACjD,OAAOJ,eAAeM,MAAM,GAAGX;IACjC;IACAS,QAAQG,IAAI,GAAG;IACf,MAAMC,UAAUJ,QAAQK,WAAW,CAACT;IACpC,OAAOQ,QAAQE,KAAK;AACtB;AAEA;;CAEC,GACD,OAAO,SAASC,iBAAiBC,IAAkD,EAAEC,IAAoB;IACvG,MAAMC,eAAe;QACnBC,MAAM;QACNC,aAAa;YAAC;YAAG;SAAM;QACvBC,WAAW;YACTC,WAAW,CAACC;gBACV,OAAOzB,YAAYyB,OAAON;YAC5B;QACF;IACF;IACA,OAAO;QAACpB,MAAMqB,cAAcF;KAAM;AACpC;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASQ,0BACdC,QAA0C,EAC1CC,UAAqC,EACrCC,iBAAkC,EAClCC,SAAoB;IAEpB,MAAMC,OAA+B,EAAE;IAEvC,kCAAkC;IAClC,MAAMC,iBAAuCjC,MAC3C;QACEsB,MAAM;QACNY,UAAU;QACVX,aAAa;YAAC;YAAG;SAAM;QACvBC,WAAW;YACTC,WAAW,CAACC;gBACV,OAAOzB,YAAYyB,OAAOG;YAC5B;YACA,yCAAyC;YACzCM,UAAU;QACZ;IACF,GACAP;IAEFI,KAAKI,IAAI,CAACH;IAEV,sEAAsE;IACtE,IAAII,mBAAmB;IAEvB,wDAAwD;IACxDP,kBAAkBQ,OAAO,CAAC,CAACjC,QAAQkC;QACjC,MAAMC,kBAAwC;YAC5ClB,MAAM;YACNY,UAAU;YACV,oEAAoE;YACpEO,QAAQJ;YACRd,aAAa;gBAAC;gBAAG;aAAM;YACvBC,WAAW;gBACTC,WAAW,CAACC;oBACV,OAAOzB,YAAYyB,OAAOrB;gBAC5B;YACF;YACAqC,WAAW;gBACTC,MAAM;YACR;YACAA,MAAMf,UAAUe;QAClB;QACAX,KAAKI,IAAI,CAACI;QACV,mEAAmE;QACnE,IAAIT,WAAW;YACbM,oBAAoBjC,mBAAmBC,QAAQ0B,SAAS,CAACQ,MAAM,IAAI,QAAQpC;QAC7E;IACF;IAEA,OAAO6B;AACT"}
@@ -1,5 +1,6 @@
1
1
  export declare function dateFormatOptionsWithTimeZone(dateFormatOptions: Intl.DateTimeFormatOptions, timeZone?: string): Intl.DateTimeFormatOptions;
2
2
  export declare function formatWithTimeZone(date: Date, formatString: string, timeZone?: string): string;
3
+ export declare function getGMTOffset(timeZone?: string): string;
3
4
  export declare function getFormattedAxisLabel(rangeMs: number): string | {
4
5
  month: '{MMM}';
5
6
  year: '{yearStyle|{yyyy}}\n{monthStyle|{MMM}}';
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAgBA,wBAAgB,6BAA6B,CAC3C,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,EAC7C,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAC,qBAAqB,CAgB5B;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9F;AAGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GACjD,MAAM,GACN;IACE,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,wCAAwC,CAAC;IAC/C,GAAG,EAAE,WAAW,CAAC;CAClB,CA8BJ;AAED,UAAU,iBAAiB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,iBAWhD,CAAC"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAgBA,wBAAgB,6BAA6B,CAC3C,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,EAC7C,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAC,qBAAqB,CAgB5B;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9F;AAED,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CA0BtD;AAGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GACjD,MAAM,GACN;IACE,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,wCAAwC,CAAC;IAC/C,GAAG,EAAE,WAAW,CAAC;CAClB,CA8BJ;AAED,UAAU,iBAAiB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,iBAWhD,CAAC"}
@@ -42,6 +42,23 @@ export function formatWithTimeZone(date, formatString, timeZone) {
42
42
  });
43
43
  }
44
44
  }
45
+ export function getGMTOffset(timeZone) {
46
+ const lower = timeZone?.toLowerCase();
47
+ const resolvedTimeZone = !timeZone || lower === 'local' || lower === 'browser' ? Intl.DateTimeFormat().resolvedOptions().timeZone : lower === 'utc' ? 'UTC' : timeZone;
48
+ try {
49
+ const formatter = new Intl.DateTimeFormat('en-US', {
50
+ timeZone: resolvedTimeZone,
51
+ timeZoneName: 'shortOffset'
52
+ });
53
+ const parts = formatter.formatToParts(new Date());
54
+ const tzPart = parts.find((p)=>p.type === 'timeZoneName');
55
+ const value = tzPart?.value ?? '';
56
+ if (value === 'GMT') return 'GMT+0';
57
+ return value;
58
+ } catch {
59
+ return 'GMT+0';
60
+ }
61
+ }
45
62
  // https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter
46
63
  export function getFormattedAxisLabel(rangeMs) {
47
64
  const dayMs = 86400000;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/format.ts"],"sourcesContent":["// Copyright 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 { tz } from '@date-fns/tz';\nimport { format } from 'date-fns';\n\nexport function dateFormatOptionsWithTimeZone(\n dateFormatOptions: Intl.DateTimeFormatOptions,\n timeZone?: string\n): Intl.DateTimeFormatOptions {\n /*\n * if timeZone is provided, and is not local|browser,\n * then set timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, default to browser timeZone setting\n */\n if (timeZone) {\n const lowerTimeZone = timeZone.toLowerCase();\n if (lowerTimeZone !== 'local' && lowerTimeZone !== 'browser') {\n return {\n ...dateFormatOptions,\n timeZone: lowerTimeZone === 'utc' ? 'UTC' : timeZone,\n };\n }\n }\n return dateFormatOptions;\n}\n\nexport function formatWithTimeZone(date: Date, formatString: string, timeZone?: string): string {\n /*\n * if timeZone is provided, and is not local|browser,\n * then format using timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, format without timeZone option, defaulting to browser timeZone setting\n */\n const lowerTimeZone = timeZone?.toLowerCase();\n if (!timeZone || lowerTimeZone === 'local' || lowerTimeZone === 'browser') {\n return format(date, formatString);\n } else {\n return format(date, formatString, { in: tz(lowerTimeZone === 'utc' ? 'UTC' : timeZone) });\n }\n}\n\n// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter\nexport function getFormattedAxisLabel(rangeMs: number):\n | string\n | {\n month: '{MMM}';\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}';\n day: '{MM}/{dd}';\n } {\n const dayMs = 86400000;\n const monthMs = 2629440000;\n const yearMs = 31536000000;\n\n // more than 5 years\n if (rangeMs > yearMs * 5) {\n return '{yyyy}';\n }\n\n // more than 2 years\n if (rangeMs > yearMs * 2) {\n return '{MMM} {yyyy}';\n }\n\n // between 5 days to 6 months\n if (rangeMs > dayMs * 5 && rangeMs < monthMs * 6) {\n return '{MM}/{dd}'; // 12/01\n }\n\n // between 2 and 5 days\n if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 5) {\n return '{MM}/{dd} {HH}:{mm}'; // 12/01 12:30\n }\n\n return {\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}',\n month: '{MMM}', // Jan, Feb, ...\n day: '{MM}/{dd}',\n };\n}\n\ninterface FormattedDateTime {\n formattedDate: string;\n formattedTime: string;\n}\n\nexport const getDateAndTime = (timeMs?: number): FormattedDateTime => {\n if (!timeMs) {\n return { formattedDate: '', formattedTime: '' };\n }\n const date = new Date(timeMs);\n const formattedDate = format(date, 'MMM dd, yyyy - ');\n const formattedTime = format(date, 'HH:mm:ss');\n return {\n formattedDate,\n formattedTime,\n };\n};\n"],"names":["tz","format","dateFormatOptionsWithTimeZone","dateFormatOptions","timeZone","lowerTimeZone","toLowerCase","formatWithTimeZone","date","formatString","in","getFormattedAxisLabel","rangeMs","dayMs","monthMs","yearMs","year","month","day","getDateAndTime","timeMs","formattedDate","formattedTime","Date"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,EAAE,QAAQ,eAAe;AAClC,SAASC,MAAM,QAAQ,WAAW;AAElC,OAAO,SAASC,8BACdC,iBAA6C,EAC7CC,QAAiB;IAEjB;;;;GAIC,GACD,IAAIA,UAAU;QACZ,MAAMC,gBAAgBD,SAASE,WAAW;QAC1C,IAAID,kBAAkB,WAAWA,kBAAkB,WAAW;YAC5D,OAAO;gBACL,GAAGF,iBAAiB;gBACpBC,UAAUC,kBAAkB,QAAQ,QAAQD;YAC9C;QACF;IACF;IACA,OAAOD;AACT;AAEA,OAAO,SAASI,mBAAmBC,IAAU,EAAEC,YAAoB,EAAEL,QAAiB;IACpF;;;;GAIC,GACD,MAAMC,gBAAgBD,UAAUE;IAChC,IAAI,CAACF,YAAYC,kBAAkB,WAAWA,kBAAkB,WAAW;QACzE,OAAOJ,OAAOO,MAAMC;IACtB,OAAO;QACL,OAAOR,OAAOO,MAAMC,cAAc;YAAEC,IAAIV,GAAGK,kBAAkB,QAAQ,QAAQD;QAAU;IACzF;AACF;AAEA,sEAAsE;AACtE,OAAO,SAASO,sBAAsBC,OAAe;IAOnD,MAAMC,QAAQ;IACd,MAAMC,UAAU;IAChB,MAAMC,SAAS;IAEf,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,6BAA6B;IAC7B,IAAIH,UAAUC,QAAQ,KAAKD,UAAUE,UAAU,GAAG;QAChD,OAAO,aAAa,QAAQ;IAC9B;IAEA,uBAAuB;IACvB,IAAIF,UAAUC,QAAQ,KAAKD,WAAWC,QAAQ,GAAG;QAC/C,OAAO,uBAAuB,cAAc;IAC9C;IAEA,OAAO;QACLG,MAAM;QACNC,OAAO;QACPC,KAAK;IACP;AACF;AAOA,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,IAAI,CAACA,QAAQ;QACX,OAAO;YAAEC,eAAe;YAAIC,eAAe;QAAG;IAChD;IACA,MAAMd,OAAO,IAAIe,KAAKH;IACtB,MAAMC,gBAAgBpB,OAAOO,MAAM;IACnC,MAAMc,gBAAgBrB,OAAOO,MAAM;IACnC,OAAO;QACLa;QACAC;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/utils/format.ts"],"sourcesContent":["// Copyright 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 { tz } from '@date-fns/tz';\nimport { format } from 'date-fns';\n\nexport function dateFormatOptionsWithTimeZone(\n dateFormatOptions: Intl.DateTimeFormatOptions,\n timeZone?: string\n): Intl.DateTimeFormatOptions {\n /*\n * if timeZone is provided, and is not local|browser,\n * then set timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, default to browser timeZone setting\n */\n if (timeZone) {\n const lowerTimeZone = timeZone.toLowerCase();\n if (lowerTimeZone !== 'local' && lowerTimeZone !== 'browser') {\n return {\n ...dateFormatOptions,\n timeZone: lowerTimeZone === 'utc' ? 'UTC' : timeZone,\n };\n }\n }\n return dateFormatOptions;\n}\n\nexport function formatWithTimeZone(date: Date, formatString: string, timeZone?: string): string {\n /*\n * if timeZone is provided, and is not local|browser,\n * then format using timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, format without timeZone option, defaulting to browser timeZone setting\n */\n const lowerTimeZone = timeZone?.toLowerCase();\n if (!timeZone || lowerTimeZone === 'local' || lowerTimeZone === 'browser') {\n return format(date, formatString);\n } else {\n return format(date, formatString, { in: tz(lowerTimeZone === 'utc' ? 'UTC' : timeZone) });\n }\n}\n\nexport function getGMTOffset(timeZone?: string): string {\n const lower = timeZone?.toLowerCase();\n\n const resolvedTimeZone =\n !timeZone || lower === 'local' || lower === 'browser'\n ? Intl.DateTimeFormat().resolvedOptions().timeZone\n : lower === 'utc'\n ? 'UTC'\n : timeZone;\n\n try {\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: resolvedTimeZone,\n timeZoneName: 'shortOffset',\n });\n\n const parts = formatter.formatToParts(new Date());\n const tzPart = parts.find((p) => p.type === 'timeZoneName');\n\n const value = tzPart?.value ?? '';\n\n if (value === 'GMT') return 'GMT+0';\n return value;\n } catch {\n return 'GMT+0';\n }\n}\n\n// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter\nexport function getFormattedAxisLabel(rangeMs: number):\n | string\n | {\n month: '{MMM}';\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}';\n day: '{MM}/{dd}';\n } {\n const dayMs = 86400000;\n const monthMs = 2629440000;\n const yearMs = 31536000000;\n\n // more than 5 years\n if (rangeMs > yearMs * 5) {\n return '{yyyy}';\n }\n\n // more than 2 years\n if (rangeMs > yearMs * 2) {\n return '{MMM} {yyyy}';\n }\n\n // between 5 days to 6 months\n if (rangeMs > dayMs * 5 && rangeMs < monthMs * 6) {\n return '{MM}/{dd}'; // 12/01\n }\n\n // between 2 and 5 days\n if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 5) {\n return '{MM}/{dd} {HH}:{mm}'; // 12/01 12:30\n }\n\n return {\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}',\n month: '{MMM}', // Jan, Feb, ...\n day: '{MM}/{dd}',\n };\n}\n\ninterface FormattedDateTime {\n formattedDate: string;\n formattedTime: string;\n}\n\nexport const getDateAndTime = (timeMs?: number): FormattedDateTime => {\n if (!timeMs) {\n return { formattedDate: '', formattedTime: '' };\n }\n const date = new Date(timeMs);\n const formattedDate = format(date, 'MMM dd, yyyy - ');\n const formattedTime = format(date, 'HH:mm:ss');\n return {\n formattedDate,\n formattedTime,\n };\n};\n"],"names":["tz","format","dateFormatOptionsWithTimeZone","dateFormatOptions","timeZone","lowerTimeZone","toLowerCase","formatWithTimeZone","date","formatString","in","getGMTOffset","lower","resolvedTimeZone","Intl","DateTimeFormat","resolvedOptions","formatter","timeZoneName","parts","formatToParts","Date","tzPart","find","p","type","value","getFormattedAxisLabel","rangeMs","dayMs","monthMs","yearMs","year","month","day","getDateAndTime","timeMs","formattedDate","formattedTime"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,EAAE,QAAQ,eAAe;AAClC,SAASC,MAAM,QAAQ,WAAW;AAElC,OAAO,SAASC,8BACdC,iBAA6C,EAC7CC,QAAiB;IAEjB;;;;GAIC,GACD,IAAIA,UAAU;QACZ,MAAMC,gBAAgBD,SAASE,WAAW;QAC1C,IAAID,kBAAkB,WAAWA,kBAAkB,WAAW;YAC5D,OAAO;gBACL,GAAGF,iBAAiB;gBACpBC,UAAUC,kBAAkB,QAAQ,QAAQD;YAC9C;QACF;IACF;IACA,OAAOD;AACT;AAEA,OAAO,SAASI,mBAAmBC,IAAU,EAAEC,YAAoB,EAAEL,QAAiB;IACpF;;;;GAIC,GACD,MAAMC,gBAAgBD,UAAUE;IAChC,IAAI,CAACF,YAAYC,kBAAkB,WAAWA,kBAAkB,WAAW;QACzE,OAAOJ,OAAOO,MAAMC;IACtB,OAAO;QACL,OAAOR,OAAOO,MAAMC,cAAc;YAAEC,IAAIV,GAAGK,kBAAkB,QAAQ,QAAQD;QAAU;IACzF;AACF;AAEA,OAAO,SAASO,aAAaP,QAAiB;IAC5C,MAAMQ,QAAQR,UAAUE;IAExB,MAAMO,mBACJ,CAACT,YAAYQ,UAAU,WAAWA,UAAU,YACxCE,KAAKC,cAAc,GAAGC,eAAe,GAAGZ,QAAQ,GAChDQ,UAAU,QACR,QACAR;IAER,IAAI;QACF,MAAMa,YAAY,IAAIH,KAAKC,cAAc,CAAC,SAAS;YACjDX,UAAUS;YACVK,cAAc;QAChB;QAEA,MAAMC,QAAQF,UAAUG,aAAa,CAAC,IAAIC;QAC1C,MAAMC,SAASH,MAAMI,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK;QAE5C,MAAMC,QAAQJ,QAAQI,SAAS;QAE/B,IAAIA,UAAU,OAAO,OAAO;QAC5B,OAAOA;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,sEAAsE;AACtE,OAAO,SAASC,sBAAsBC,OAAe;IAOnD,MAAMC,QAAQ;IACd,MAAMC,UAAU;IAChB,MAAMC,SAAS;IAEf,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,6BAA6B;IAC7B,IAAIH,UAAUC,QAAQ,KAAKD,UAAUE,UAAU,GAAG;QAChD,OAAO,aAAa,QAAQ;IAC9B;IAEA,uBAAuB;IACvB,IAAIF,UAAUC,QAAQ,KAAKD,WAAWC,QAAQ,GAAG;QAC/C,OAAO,uBAAuB,cAAc;IAC9C;IAEA,OAAO;QACLG,MAAM;QACNC,OAAO;QACPC,KAAK;IACP;AACF;AAOA,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,IAAI,CAACA,QAAQ;QACX,OAAO;YAAEC,eAAe;YAAIC,eAAe;QAAG;IAChD;IACA,MAAM9B,OAAO,IAAIa,KAAKe;IACtB,MAAMC,gBAAgBpC,OAAOO,MAAM;IACnC,MAAM8B,gBAAgBrC,OAAOO,MAAM;IACnC,OAAO;QACL6B;QACAC;IACF;AACF,EAAE"}
@@ -6,6 +6,7 @@ export * from './component-ids';
6
6
  export * from './data-field-interpolation';
7
7
  export * from './format';
8
8
  export * from './memo';
9
+ export * from './request-interpolation';
9
10
  export * from './selection-interpolation';
10
11
  export * from './theme-gen';
11
12
  export * from './variable-interpolation';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC"}
@@ -18,6 +18,7 @@ export * from './component-ids';
18
18
  export * from './data-field-interpolation';
19
19
  export * from './format';
20
20
  export * from './memo';
21
+ export * from './request-interpolation';
21
22
  export * from './selection-interpolation';
22
23
  export * from './theme-gen';
23
24
  export * from './variable-interpolation';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 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 './axis';\nexport * from './browser-storage';\nexport * from './chart-actions';\nexport * from './combine-sx';\nexport * from './component-ids';\nexport * from './data-field-interpolation';\nexport * from './format';\nexport * from './memo';\nexport * from './selection-interpolation';\nexport * from './theme-gen';\nexport * from './variable-interpolation';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,4BAA4B;AAC1C,cAAc,cAAc;AAC5B,cAAc,2BAA2B"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 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 './axis';\nexport * from './browser-storage';\nexport * from './chart-actions';\nexport * from './combine-sx';\nexport * from './component-ids';\nexport * from './data-field-interpolation';\nexport * from './format';\nexport * from './memo';\nexport * from './request-interpolation';\nexport * from './selection-interpolation';\nexport * from './theme-gen';\nexport * from './variable-interpolation';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,cAAc;AAC5B,cAAc,2BAA2B"}
@@ -0,0 +1,6 @@
1
+ import { RequestHeaders } from '@perses-dev/client';
2
+ import { VariableStateMap } from './variable-interpolation';
3
+ export type QueryParamValues = Record<string, string | string[]>;
4
+ export declare function interpolateHeaders(headers: Record<string, string>, variableState: VariableStateMap): RequestHeaders;
5
+ export declare function interpolateQueryParams(queryParams: QueryParamValues, variableState: VariableStateMap): QueryParamValues;
6
+ //# sourceMappingURL=request-interpolation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-interpolation.d.ts","sourceRoot":"","sources":["../../src/utils/request-interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAoB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEjE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,gBAAgB,GAAG,cAAc,CAMnH;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,gBAAgB,EAC7B,aAAa,EAAE,gBAAgB,GAC9B,gBAAgB,CAUlB"}
@@ -0,0 +1,33 @@
1
+ // Copyright 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 { replaceVariables } from './variable-interpolation';
14
+ export function interpolateHeaders(headers, variableState) {
15
+ const result = {};
16
+ for (const [key, value] of Object.entries(headers)){
17
+ result[key] = replaceVariables(value, variableState);
18
+ }
19
+ return result;
20
+ }
21
+ export function interpolateQueryParams(queryParams, variableState) {
22
+ const result = {};
23
+ for (const [key, value] of Object.entries(queryParams)){
24
+ if (Array.isArray(value)) {
25
+ result[key] = value.map((v)=>replaceVariables(v, variableState));
26
+ } else {
27
+ result[key] = replaceVariables(value, variableState);
28
+ }
29
+ }
30
+ return result;
31
+ }
32
+
33
+ //# sourceMappingURL=request-interpolation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/request-interpolation.ts"],"sourcesContent":["// Copyright 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 { RequestHeaders } from '@perses-dev/client';\nimport { replaceVariables, VariableStateMap } from './variable-interpolation';\n\nexport type QueryParamValues = Record<string, string | string[]>;\n\nexport function interpolateHeaders(headers: Record<string, string>, variableState: VariableStateMap): RequestHeaders {\n const result: RequestHeaders = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key] = replaceVariables(value, variableState);\n }\n return result;\n}\n\nexport function interpolateQueryParams(\n queryParams: QueryParamValues,\n variableState: VariableStateMap\n): QueryParamValues {\n const result: QueryParamValues = {};\n for (const [key, value] of Object.entries(queryParams)) {\n if (Array.isArray(value)) {\n result[key] = value.map((v) => replaceVariables(v, variableState));\n } else {\n result[key] = replaceVariables(value, variableState);\n }\n }\n return result;\n}\n"],"names":["replaceVariables","interpolateHeaders","headers","variableState","result","key","value","Object","entries","interpolateQueryParams","queryParams","Array","isArray","map","v"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,gBAAgB,QAA0B,2BAA2B;AAI9E,OAAO,SAASC,mBAAmBC,OAA+B,EAAEC,aAA+B;IACjG,MAAMC,SAAyB,CAAC;IAChC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACN,SAAU;QAClDE,MAAM,CAACC,IAAI,GAAGL,iBAAiBM,OAAOH;IACxC;IACA,OAAOC;AACT;AAEA,OAAO,SAASK,uBACdC,WAA6B,EAC7BP,aAA+B;IAE/B,MAAMC,SAA2B,CAAC;IAClC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACE,aAAc;QACtD,IAAIC,MAAMC,OAAO,CAACN,QAAQ;YACxBF,MAAM,CAACC,IAAI,GAAGC,MAAMO,GAAG,CAAC,CAACC,IAAMd,iBAAiBc,GAAGX;QACrD,OAAO;YACLC,MAAM,CAACC,IAAI,GAAGL,iBAAiBM,OAAOH;QACxC;IACF;IACA,OAAOC;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.54.0-beta.0",
3
+ "version": "0.54.0-beta.2",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -34,8 +34,10 @@
34
34
  "@date-fns/tz": "^1.4.1",
35
35
  "@fontsource/inter": "^5.0.0",
36
36
  "@mui/x-date-pickers": "^7.23.1",
37
- "@perses-dev/core": "0.53.0",
38
37
  "@perses-dev/spec": "0.2.0-beta.0",
38
+ "@perses-dev/client": "0.54.0-beta.2",
39
+ "numbro": "^2.3.6",
40
+ "@tanstack/match-sorter-utils": "^8.19.4",
39
41
  "@tanstack/react-table": "^8.20.5",
40
42
  "@uiw/react-codemirror": "^4.19.1",
41
43
  "date-fns": "^4.1.0",