@perses-dev/components 0.53.1 → 0.54.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
  2. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  3. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
  4. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
  6. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  7. package/dist/FormEditor/FormActions.d.ts +1 -1
  8. package/dist/FormEditor/FormActions.d.ts.map +1 -1
  9. package/dist/FormEditor/FormActions.js.map +1 -1
  10. package/dist/FormatControls/FormatControls.d.ts +1 -1
  11. package/dist/FormatControls/FormatControls.d.ts.map +1 -1
  12. package/dist/FormatControls/FormatControls.js +1 -1
  13. package/dist/FormatControls/FormatControls.js.map +1 -1
  14. package/dist/FormatControls/UnitSelector.d.ts +1 -1
  15. package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
  16. package/dist/FormatControls/UnitSelector.js +1 -1
  17. package/dist/FormatControls/UnitSelector.js.map +1 -1
  18. package/dist/Legend/Legend.js +1 -1
  19. package/dist/Legend/Legend.js.map +1 -1
  20. package/dist/Legend/legend-model.d.ts +1 -1
  21. package/dist/Legend/legend-model.d.ts.map +1 -1
  22. package/dist/Legend/legend-model.js.map +1 -1
  23. package/dist/LinksEditor/LinksEditor.d.ts +1 -1
  24. package/dist/LinksEditor/LinksEditor.js.map +1 -1
  25. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +1 -1
  26. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  27. package/dist/Table/Table.d.ts +1 -1
  28. package/dist/Table/Table.d.ts.map +1 -1
  29. package/dist/Table/Table.js +26 -6
  30. package/dist/Table/Table.js.map +1 -1
  31. package/dist/Table/TableToolbar.d.ts +34 -0
  32. package/dist/Table/TableToolbar.d.ts.map +1 -0
  33. package/dist/Table/TableToolbar.js +127 -0
  34. package/dist/Table/TableToolbar.js.map +1 -0
  35. package/dist/Table/VirtualizedTable.d.ts +3 -1
  36. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  37. package/dist/Table/VirtualizedTable.js +128 -117
  38. package/dist/Table/VirtualizedTable.js.map +1 -1
  39. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
  40. package/dist/Table/VirtualizedTableContainer.js +5 -1
  41. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  42. package/dist/Table/hooks/useFuzzySearch.d.ts +12 -0
  43. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
  44. package/dist/Table/hooks/useFuzzySearch.js +43 -0
  45. package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
  46. package/dist/Table/model/table-model.d.ts +38 -4
  47. package/dist/Table/model/table-model.d.ts.map +1 -1
  48. package/dist/Table/model/table-model.js.map +1 -1
  49. package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
  50. package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
  51. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  52. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
  53. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  54. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  55. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +2 -3
  56. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -1
  57. package/dist/TimeRangeSelector/DateTimeRangePicker.js +2 -0
  58. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  59. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
  60. package/dist/TimeRangeSelector/TimeRangeSelector.js +1 -1
  61. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  62. package/dist/TimeRangeSelector/utils.d.ts +1 -1
  63. package/dist/TimeRangeSelector/utils.js +1 -1
  64. package/dist/TimeRangeSelector/utils.js.map +1 -1
  65. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +2 -2
  66. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  67. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  68. package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
  69. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  70. package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
  71. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  72. package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
  73. package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
  74. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  75. package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
  76. package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
  77. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  78. package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
  79. package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
  80. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  81. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  82. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
  83. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  84. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
  85. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
  86. package/dist/cjs/FormatControls/FormatControls.js +4 -4
  87. package/dist/cjs/FormatControls/UnitSelector.js +3 -3
  88. package/dist/cjs/Legend/Legend.js +2 -2
  89. package/dist/cjs/Table/Table.js +24 -4
  90. package/dist/cjs/Table/TableToolbar.js +140 -0
  91. package/dist/cjs/Table/VirtualizedTable.js +126 -115
  92. package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
  93. package/dist/cjs/Table/hooks/useFuzzySearch.js +48 -0
  94. package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -0
  95. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +3 -3
  96. package/dist/cjs/TimeRangeSelector/utils.js +2 -2
  97. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
  98. package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
  99. package/dist/cjs/model/action.js +43 -0
  100. package/dist/cjs/model/bits.js +113 -0
  101. package/dist/cjs/model/bytes.js +115 -0
  102. package/dist/cjs/model/constants.js +23 -0
  103. package/dist/cjs/model/currency.js +126 -0
  104. package/dist/cjs/model/date.js +297 -0
  105. package/dist/cjs/model/decimal.js +72 -0
  106. package/dist/cjs/model/formatterCache.js +120 -0
  107. package/dist/cjs/model/index.js +16 -0
  108. package/dist/cjs/model/legend.js +101 -0
  109. package/dist/cjs/model/percent.js +82 -0
  110. package/dist/cjs/model/temperature.js +72 -0
  111. package/dist/cjs/model/thresholds.js +16 -0
  112. package/dist/cjs/model/throughput.js +161 -0
  113. package/dist/cjs/model/time.js +178 -0
  114. package/dist/cjs/model/timeOption.js +2 -2
  115. package/dist/cjs/model/transforms.js +29 -0
  116. package/dist/cjs/model/types.js +16 -0
  117. package/dist/cjs/model/units.js +186 -0
  118. package/dist/cjs/model/utils.js +48 -0
  119. package/dist/cjs/theme/theme.js +44 -29
  120. package/dist/cjs/theme/typography.js +8 -7
  121. package/dist/cjs/utils/axis.js +5 -5
  122. package/dist/cjs/utils/index.js +1 -0
  123. package/dist/cjs/utils/request-interpolation.js +49 -0
  124. package/dist/model/action.d.ts +4 -0
  125. package/dist/model/action.d.ts.map +1 -0
  126. package/dist/model/action.js +27 -0
  127. package/dist/model/action.js.map +1 -0
  128. package/dist/model/bits.d.ts +12 -0
  129. package/dist/model/bits.d.ts.map +1 -0
  130. package/dist/model/bits.js +89 -0
  131. package/dist/model/bits.js.map +1 -0
  132. package/dist/model/bytes.d.ts +12 -0
  133. package/dist/model/bytes.d.ts.map +1 -0
  134. package/dist/model/bytes.js +91 -0
  135. package/dist/model/bytes.js.map +1 -0
  136. package/dist/model/constants.d.ts +2 -0
  137. package/dist/model/constants.d.ts.map +1 -0
  138. package/dist/model/constants.js +15 -0
  139. package/dist/model/constants.js.map +1 -0
  140. package/dist/model/currency.d.ts +11 -0
  141. package/dist/model/currency.d.ts.map +1 -0
  142. package/dist/model/currency.js +107 -0
  143. package/dist/model/currency.js.map +1 -0
  144. package/dist/model/date.d.ts +28 -0
  145. package/dist/model/date.d.ts.map +1 -0
  146. package/dist/model/date.js +278 -0
  147. package/dist/model/date.js.map +1 -0
  148. package/dist/model/decimal.d.ts +12 -0
  149. package/dist/model/decimal.d.ts.map +1 -0
  150. package/dist/model/decimal.js +53 -0
  151. package/dist/model/decimal.js.map +1 -0
  152. package/dist/model/formatterCache.d.ts +11 -0
  153. package/dist/model/formatterCache.d.ts.map +1 -0
  154. package/dist/model/formatterCache.js +104 -0
  155. package/dist/model/formatterCache.js.map +1 -0
  156. package/dist/model/graph.d.ts +1 -1
  157. package/dist/model/graph.js.map +1 -1
  158. package/dist/model/index.d.ts +16 -0
  159. package/dist/model/index.d.ts.map +1 -1
  160. package/dist/model/index.js +16 -0
  161. package/dist/model/index.js.map +1 -1
  162. package/dist/model/legend.d.ts +19 -0
  163. package/dist/model/legend.d.ts.map +1 -0
  164. package/dist/model/legend.js +61 -0
  165. package/dist/model/legend.js.map +1 -0
  166. package/dist/model/percent.d.ts +11 -0
  167. package/dist/model/percent.d.ts.map +1 -0
  168. package/dist/model/percent.js +63 -0
  169. package/dist/model/percent.js.map +1 -0
  170. package/dist/model/temperature.d.ts +11 -0
  171. package/dist/model/temperature.d.ts.map +1 -0
  172. package/dist/model/temperature.js +53 -0
  173. package/dist/model/temperature.js.map +1 -0
  174. package/dist/model/theme.d.ts +1 -1
  175. package/dist/model/theme.d.ts.map +1 -1
  176. package/dist/model/theme.js.map +1 -1
  177. package/dist/model/thresholds.d.ts +16 -0
  178. package/dist/model/thresholds.d.ts.map +1 -0
  179. package/dist/model/thresholds.js +15 -0
  180. package/dist/model/thresholds.js.map +1 -0
  181. package/dist/model/throughput.d.ts +12 -0
  182. package/dist/model/throughput.d.ts.map +1 -0
  183. package/dist/model/throughput.js +142 -0
  184. package/dist/model/throughput.js.map +1 -0
  185. package/dist/model/time.d.ts +23 -0
  186. package/dist/model/time.d.ts.map +1 -0
  187. package/dist/model/time.js +158 -0
  188. package/dist/model/time.js.map +1 -0
  189. package/dist/model/timeOption.d.ts +1 -1
  190. package/dist/model/timeOption.js +1 -1
  191. package/dist/model/timeOption.js.map +1 -1
  192. package/dist/model/transforms.d.ts +43 -0
  193. package/dist/model/transforms.d.ts.map +1 -0
  194. package/dist/model/transforms.js +22 -0
  195. package/dist/model/transforms.js.map +1 -0
  196. package/dist/model/types.d.ts +56 -0
  197. package/dist/model/types.d.ts.map +1 -0
  198. package/dist/model/types.js +15 -0
  199. package/dist/model/types.js.map +1 -0
  200. package/dist/model/units.d.ts +105 -0
  201. package/dist/model/units.d.ts.map +1 -0
  202. package/dist/model/units.js +132 -0
  203. package/dist/model/units.js.map +1 -0
  204. package/dist/model/utils.d.ts +4 -0
  205. package/dist/model/utils.d.ts.map +1 -0
  206. package/dist/model/utils.js +32 -0
  207. package/dist/model/utils.js.map +1 -0
  208. package/dist/theme/theme.d.ts +3 -1
  209. package/dist/theme/theme.d.ts.map +1 -1
  210. package/dist/theme/theme.js +46 -29
  211. package/dist/theme/theme.js.map +1 -1
  212. package/dist/theme/typography.d.ts +6 -4
  213. package/dist/theme/typography.d.ts.map +1 -1
  214. package/dist/theme/typography.js +8 -7
  215. package/dist/theme/typography.js.map +1 -1
  216. package/dist/utils/axis.d.ts +1 -1
  217. package/dist/utils/axis.d.ts.map +1 -1
  218. package/dist/utils/axis.js +1 -1
  219. package/dist/utils/axis.js.map +1 -1
  220. package/dist/utils/chart-actions.d.ts +1 -1
  221. package/dist/utils/chart-actions.js.map +1 -1
  222. package/dist/utils/index.d.ts +1 -0
  223. package/dist/utils/index.d.ts.map +1 -1
  224. package/dist/utils/index.js +1 -0
  225. package/dist/utils/index.js.map +1 -1
  226. package/dist/utils/request-interpolation.d.ts +6 -0
  227. package/dist/utils/request-interpolation.d.ts.map +1 -0
  228. package/dist/utils/request-interpolation.js +33 -0
  229. package/dist/utils/request-interpolation.js.map +1 -0
  230. package/dist/utils/variable-interpolation.d.ts +1 -1
  231. package/dist/utils/variable-interpolation.js.map +1 -1
  232. package/package.json +6 -2
@@ -12,7 +12,7 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box, useTheme } from '@mui/material';
15
- import { getLegendSize } from '@perses-dev/core';
15
+ import { getLegendSize } from '../model';
16
16
  import { Legend } from '../Legend';
17
17
  import { getContentWithLegendLayout } from './model/content-with-legend-model';
18
18
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ContentWithLegend/ContentWithLegend.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 { ReactElement } from 'react';\nimport { Box, useTheme } from '@mui/material';\nimport { getLegendSize } from '@perses-dev/core';\nimport { Legend } from '../Legend';\nimport { ContentWithLegendProps, getContentWithLegendLayout } from './model/content-with-legend-model';\n\n/**\n * Component to help lay out content alongside a `Legend` component based on the\n * configuration of the legend.\n *\n * See the documentation for the `Legend` component for more details about the\n * features and configuration of the legend.\n */\nexport function ContentWithLegend({\n children,\n legendProps,\n width,\n height,\n spacing = 0,\n legendSize,\n minChildrenWidth = 100,\n minChildrenHeight = 100,\n}: ContentWithLegendProps): ReactElement {\n const theme = useTheme();\n const { content, legend, margin } = getContentWithLegendLayout({\n width,\n height,\n legendProps,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n legendSize: getLegendSize(legendSize),\n });\n\n return (\n <Box\n style={{\n width,\n height,\n }}\n sx={{\n position: 'relative',\n overflow: 'hidden',\n }}\n >\n <Box\n style={{\n width: content.width,\n height: content.height,\n }}\n sx={{\n marginRight: `${margin.right}px`,\n marginBottom: `${margin.bottom}px`,\n }}\n >\n {typeof children === 'function' ? children({ width: content.width, height: content.height }) : children}\n </Box>\n {legendProps && legend.show && <Legend {...legendProps} height={legend.height} width={legend.width} />}\n </Box>\n );\n}\n"],"names":["Box","useTheme","getLegendSize","Legend","getContentWithLegendLayout","ContentWithLegend","children","legendProps","width","height","spacing","legendSize","minChildrenWidth","minChildrenHeight","theme","content","legend","margin","style","sx","position","overflow","marginRight","right","marginBottom","bottom","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;;AAGjC,SAASA,GAAG,EAAEC,QAAQ,QAAQ,gBAAgB;AAC9C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,MAAM,QAAQ,YAAY;AACnC,SAAiCC,0BAA0B,QAAQ,oCAAoC;AAEvG;;;;;;CAMC,GACD,OAAO,SAASC,kBAAkB,EAChCC,QAAQ,EACRC,WAAW,EACXC,KAAK,EACLC,MAAM,EACNC,UAAU,CAAC,EACXC,UAAU,EACVC,mBAAmB,GAAG,EACtBC,oBAAoB,GAAG,EACA;IACvB,MAAMC,QAAQb;IACd,MAAM,EAAEc,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGb,2BAA2B;QAC7DI;QACAC;QACAF;QACAM;QACAD;QACAF;QACAI;QACAH,YAAYT,cAAcS;IAC5B;IAEA,qBACE,MAACX;QACCkB,OAAO;YACLV;YACAC;QACF;QACAU,IAAI;YACFC,UAAU;YACVC,UAAU;QACZ;;0BAEA,KAACrB;gBACCkB,OAAO;oBACLV,OAAOO,QAAQP,KAAK;oBACpBC,QAAQM,QAAQN,MAAM;gBACxB;gBACAU,IAAI;oBACFG,aAAa,GAAGL,OAAOM,KAAK,CAAC,EAAE,CAAC;oBAChCC,cAAc,GAAGP,OAAOQ,MAAM,CAAC,EAAE,CAAC;gBACpC;0BAEC,OAAOnB,aAAa,aAAaA,SAAS;oBAAEE,OAAOO,QAAQP,KAAK;oBAAEC,QAAQM,QAAQN,MAAM;gBAAC,KAAKH;;YAEhGC,eAAeS,OAAOU,IAAI,kBAAI,KAACvB;gBAAQ,GAAGI,WAAW;gBAAEE,QAAQO,OAAOP,MAAM;gBAAED,OAAOQ,OAAOR,KAAK;;;;AAGxG"}
1
+ {"version":3,"sources":["../../src/ContentWithLegend/ContentWithLegend.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 { ReactElement } from 'react';\nimport { Box, useTheme } from '@mui/material';\nimport { getLegendSize } from '../model';\nimport { Legend } from '../Legend';\nimport { ContentWithLegendProps, getContentWithLegendLayout } from './model/content-with-legend-model';\n\n/**\n * Component to help lay out content alongside a `Legend` component based on the\n * configuration of the legend.\n *\n * See the documentation for the `Legend` component for more details about the\n * features and configuration of the legend.\n */\nexport function ContentWithLegend({\n children,\n legendProps,\n width,\n height,\n spacing = 0,\n legendSize,\n minChildrenWidth = 100,\n minChildrenHeight = 100,\n}: ContentWithLegendProps): ReactElement {\n const theme = useTheme();\n const { content, legend, margin } = getContentWithLegendLayout({\n width,\n height,\n legendProps,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n legendSize: getLegendSize(legendSize),\n });\n\n return (\n <Box\n style={{\n width,\n height,\n }}\n sx={{\n position: 'relative',\n overflow: 'hidden',\n }}\n >\n <Box\n style={{\n width: content.width,\n height: content.height,\n }}\n sx={{\n marginRight: `${margin.right}px`,\n marginBottom: `${margin.bottom}px`,\n }}\n >\n {typeof children === 'function' ? children({ width: content.width, height: content.height }) : children}\n </Box>\n {legendProps && legend.show && <Legend {...legendProps} height={legend.height} width={legend.width} />}\n </Box>\n );\n}\n"],"names":["Box","useTheme","getLegendSize","Legend","getContentWithLegendLayout","ContentWithLegend","children","legendProps","width","height","spacing","legendSize","minChildrenWidth","minChildrenHeight","theme","content","legend","margin","style","sx","position","overflow","marginRight","right","marginBottom","bottom","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;;AAGjC,SAASA,GAAG,EAAEC,QAAQ,QAAQ,gBAAgB;AAC9C,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,MAAM,QAAQ,YAAY;AACnC,SAAiCC,0BAA0B,QAAQ,oCAAoC;AAEvG;;;;;;CAMC,GACD,OAAO,SAASC,kBAAkB,EAChCC,QAAQ,EACRC,WAAW,EACXC,KAAK,EACLC,MAAM,EACNC,UAAU,CAAC,EACXC,UAAU,EACVC,mBAAmB,GAAG,EACtBC,oBAAoB,GAAG,EACA;IACvB,MAAMC,QAAQb;IACd,MAAM,EAAEc,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGb,2BAA2B;QAC7DI;QACAC;QACAF;QACAM;QACAD;QACAF;QACAI;QACAH,YAAYT,cAAcS;IAC5B;IAEA,qBACE,MAACX;QACCkB,OAAO;YACLV;YACAC;QACF;QACAU,IAAI;YACFC,UAAU;YACVC,UAAU;QACZ;;0BAEA,KAACrB;gBACCkB,OAAO;oBACLV,OAAOO,QAAQP,KAAK;oBACpBC,QAAQM,QAAQN,MAAM;gBACxB;gBACAU,IAAI;oBACFG,aAAa,GAAGL,OAAOM,KAAK,CAAC,EAAE,CAAC;oBAChCC,cAAc,GAAGP,OAAOQ,MAAM,CAAC,EAAE,CAAC;gBACpC;0BAEC,OAAOnB,aAAa,aAAaA,SAAS;oBAAEE,OAAOO,QAAQP,KAAK;oBAAEC,QAAQM,QAAQN,MAAM;gBAAC,KAAKH;;YAEhGC,eAAeS,OAAOU,IAAI,kBAAI,KAACvB;gBAAQ,GAAGI,WAAW;gBAAEE,QAAQO,OAAOP,MAAM;gBAAED,OAAOQ,OAAOR,KAAK;;;;AAGxG"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { Theme } from '@mui/material';
3
- import { LegendPositions, LegendSize } from '@perses-dev/core';
3
+ import { LegendPositions, LegendSize } from '../../model';
4
4
  import { LegendProps } from '../../Legend';
5
5
  type Dimensions = {
6
6
  width: number;
@@ -1 +1 @@
1
- {"version":3,"file":"content-with-legend-model.d.ts","sourceRoot":"","sources":["../../../src/ContentWithLegend/model/content-with-legend-model.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAiB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC;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AAE,2BAA2B,GAAG,uBAAuB,CAwFvD"}
1
+ {"version":3,"file":"content-with-legend-model.d.ts","sourceRoot":"","sources":["../../../src/ContentWithLegend/model/content-with-legend-model.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAiB,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAEjF;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC;IAEpD;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,2BACf,SAAQ,QAAQ,CAAC,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,aAAa,CAAC,CAAC;IAC1E,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACpD,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,UAAU,GAAG;QACnB,IAAI,EAAE,OAAO,CAAC;KACf,CAAC;IACF,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,KAAK,gBAAgB,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E,eAAO,MAAM,iBAAiB,EAAE,gBAe/B,CAAC;AAMF;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,KAAK,EACL,MAAM,EACN,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,KAAK,GACN,EAAE,2BAA2B,GAAG,uBAAuB,CAwFvD"}
@@ -10,7 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { getLegendMode } from '@perses-dev/core';
13
+ import { getLegendMode } from '../../model';
14
14
  import { getTableCellLayout } from '../../Table';
15
15
  export const TABLE_LEGEND_SIZE = {
16
16
  medium: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ContentWithLegend/model/content-with-legend-model.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 { Theme } from '@mui/material';\nimport { LegendPositions, getLegendMode, LegendSize } from '@perses-dev/core';\nimport { LegendProps } from '../../Legend';\nimport { getTableCellLayout } from '../../Table';\n\ntype Dimensions = {\n width: number;\n height: number;\n};\n\nexport interface ContentWithLegendProps {\n /**\n * Width of the overall component layout in pixels.\n */\n width: number;\n /**\n * Height of overall component layout in pixels.\n */\n height: number;\n /**\n * Child content to render next to the legend. May be a react node or a\n * function that returns a react node. The function provides the expected\n * height and width for the content, which can be useful for passing down\n * to chart components.\n */\n children: React.ReactNode | (({ width, height }: Dimensions) => React.ReactNode);\n\n /**\n * Size used for the legend.\n *\n * @default 'medium'\n */\n legendSize?: LegendSize;\n\n /**\n * Props to configure the legend. If not set, the content is rendered without\n * a legend.\n */\n legendProps?: Omit<LegendProps, 'width' | 'height'>;\n\n /**\n * Space to put between the children and the legend in pixels.\n */\n spacing?: number;\n\n /**\n * Minimum width required for the content specified by the `children` prop.\n * If this width cannot be maintained with a right positioned legend, the\n * legend will not be shown.\n */\n minChildrenWidth?: number;\n\n /**\n * Minimum height required for the content specified by the `children` prop.\n * If this width cannot be maintained with a bottom positioned legend, the\n * legend will not be shown.\n */\n minChildrenHeight?: number;\n}\n\nexport interface ContentWithLegendLayoutOpts\n extends Required<Omit<ContentWithLegendProps, 'children' | 'legendProps'>> {\n legendProps?: ContentWithLegendProps['legendProps'];\n theme: Theme;\n}\n\nexport interface ContentWithLegendLayout {\n legend: Dimensions & {\n show: boolean;\n };\n content: Dimensions;\n margin: {\n right: number;\n bottom: number;\n };\n}\n\ntype LegendSizeConfig = Record<LegendSize, Record<LegendPositions, number>>;\n\nexport const TABLE_LEGEND_SIZE: LegendSizeConfig = {\n medium: {\n // 5 rows plus header. Value to be multiplied by row height in pixels.\n bottom: 6,\n\n // Pixel value\n right: 250,\n },\n small: {\n // 3 rows plus header. Value to be multiplied by row height in pixels.\n bottom: 4,\n\n // Pixel value\n right: 150,\n },\n};\n\nconst PANEL_HEIGHT_LG_BREAKPOINT = 300;\nconst LEGEND_HEIGHT_SM = 40;\nconst LEGEND_HEIGHT_LG = 100;\n\n/**\n * Returns information for laying out content alongside a legend.\n */\nexport function getContentWithLegendLayout({\n width,\n height,\n legendProps,\n legendSize,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n}: ContentWithLegendLayoutOpts): ContentWithLegendLayout {\n const legendOptions = legendProps?.options;\n const hasLegend = !!legendOptions;\n\n const noLegendLayout: ContentWithLegendLayout = {\n legend: {\n show: false,\n width: 0,\n height: 0,\n },\n content: {\n width,\n height,\n },\n margin: {\n right: 0,\n bottom: 0,\n },\n };\n\n if (!hasLegend) {\n return noLegendLayout;\n }\n\n const { position } = legendOptions;\n const mode = getLegendMode(legendOptions.mode);\n\n let legendWidth;\n let legendHeight;\n\n if (mode === 'list') {\n // TODO: normalize list to share similar height options as the table\n // when we add more size options.\n legendWidth = position === 'right' ? 200 : width;\n\n // TODO: account for number of legend items returned when adjusting legend spacing\n legendHeight = LEGEND_HEIGHT_SM;\n if (position === 'right') {\n legendHeight = height;\n } else if (height >= PANEL_HEIGHT_LG_BREAKPOINT) {\n legendHeight = LEGEND_HEIGHT_LG;\n }\n } else {\n // Table mode\n\n const tableLayout = getTableCellLayout(theme, 'compact');\n\n const tableColumns = legendProps?.tableProps?.columns || [];\n const columnsWidth = tableColumns.reduce((total, col) => {\n if (typeof col.width === 'number') {\n total += col.width;\n }\n return total;\n }, 0);\n\n legendWidth = position === 'right' ? TABLE_LEGEND_SIZE[legendSize]['right'] + columnsWidth : width;\n\n // Use the smaller of the size-based row count or the number of legend items + 1 for the header.\n const rowsToShow = Math.min(TABLE_LEGEND_SIZE[legendSize]['bottom'], legendProps.data.length + 1);\n legendHeight = position === 'bottom' ? rowsToShow * tableLayout.height : height;\n }\n\n const contentWidth = position === 'right' ? width - legendWidth - spacing : width;\n const contentHeight = position === 'bottom' ? height - legendHeight - spacing : height;\n\n if (\n (position === 'right' && contentWidth < minChildrenWidth) ||\n (position === 'bottom' && contentHeight < minChildrenHeight)\n ) {\n // Legend does not fit. Just show the content.\n return noLegendLayout;\n }\n\n return {\n legend: {\n width: legendWidth,\n height: legendHeight,\n show: true,\n },\n content: {\n width: contentWidth,\n height: contentHeight,\n },\n margin: {\n right: position === 'right' ? spacing : 0,\n bottom: position === 'bottom' ? spacing : 0,\n },\n };\n}\n"],"names":["getLegendMode","getTableCellLayout","TABLE_LEGEND_SIZE","medium","bottom","right","small","PANEL_HEIGHT_LG_BREAKPOINT","LEGEND_HEIGHT_SM","LEGEND_HEIGHT_LG","getContentWithLegendLayout","width","height","legendProps","legendSize","minChildrenHeight","minChildrenWidth","spacing","theme","legendOptions","options","hasLegend","noLegendLayout","legend","show","content","margin","position","mode","legendWidth","legendHeight","tableLayout","tableColumns","tableProps","columns","columnsWidth","reduce","total","col","rowsToShow","Math","min","data","length","contentWidth","contentHeight"],"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,SAA0BA,aAAa,QAAoB,mBAAmB;AAE9E,SAASC,kBAAkB,QAAQ,cAAc;AA4EjD,OAAO,MAAMC,oBAAsC;IACjDC,QAAQ;QACN,sEAAsE;QACtEC,QAAQ;QAER,cAAc;QACdC,OAAO;IACT;IACAC,OAAO;QACL,sEAAsE;QACtEF,QAAQ;QAER,cAAc;QACdC,OAAO;IACT;AACF,EAAE;AAEF,MAAME,6BAA6B;AACnC,MAAMC,mBAAmB;AACzB,MAAMC,mBAAmB;AAEzB;;CAEC,GACD,OAAO,SAASC,2BAA2B,EACzCC,KAAK,EACLC,MAAM,EACNC,WAAW,EACXC,UAAU,EACVC,iBAAiB,EACjBC,gBAAgB,EAChBC,OAAO,EACPC,KAAK,EACuB;IAC5B,MAAMC,gBAAgBN,aAAaO;IACnC,MAAMC,YAAY,CAAC,CAACF;IAEpB,MAAMG,iBAA0C;QAC9CC,QAAQ;YACNC,MAAM;YACNb,OAAO;YACPC,QAAQ;QACV;QACAa,SAAS;YACPd;YACAC;QACF;QACAc,QAAQ;YACNrB,OAAO;YACPD,QAAQ;QACV;IACF;IAEA,IAAI,CA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AAOiC;YACPhC,QAAQiC;QACV;QACAnB,QAAQ;YACNrB,OAAOsB,aAAa,UAAUV,UAAU;YACxCb,QAAQuB,aAAa,WAAWV,UAAU;QAC5C;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/ContentWithLegend/model/content-with-legend-model.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 { Theme } from '@mui/material';\nimport { LegendPositions, getLegendMode, LegendSize } from '../../model';\nimport { LegendProps } from '../../Legend';\nimport { getTableCellLayout } from '../../Table';\n\ntype Dimensions = {\n width: number;\n height: number;\n};\n\nexport interface ContentWithLegendProps {\n /**\n * Width of the overall component layout in pixels.\n */\n width: number;\n /**\n * Height of overall component layout in pixels.\n */\n height: number;\n /**\n * Child content to render next to the legend. May be a react node or a\n * function that returns a react node. The function provides the expected\n * height and width for the content, which can be useful for passing down\n * to chart components.\n */\n children: React.ReactNode | (({ width, height }: Dimensions) => React.ReactNode);\n\n /**\n * Size used for the legend.\n *\n * @default 'medium'\n */\n legendSize?: LegendSize;\n\n /**\n * Props to configure the legend. If not set, the content is rendered without\n * a legend.\n */\n legendProps?: Omit<LegendProps, 'width' | 'height'>;\n\n /**\n * Space to put between the children and the legend in pixels.\n */\n spacing?: number;\n\n /**\n * Minimum width required for the content specified by the `children` prop.\n * If this width cannot be maintained with a right positioned legend, the\n * legend will not be shown.\n */\n minChildrenWidth?: number;\n\n /**\n * Minimum height required for the content specified by the `children` prop.\n * If this width cannot be maintained with a bottom positioned legend, the\n * legend will not be shown.\n */\n minChildrenHeight?: number;\n}\n\nexport interface ContentWithLegendLayoutOpts\n extends Required<Omit<ContentWithLegendProps, 'children' | 'legendProps'>> {\n legendProps?: ContentWithLegendProps['legendProps'];\n theme: Theme;\n}\n\nexport interface ContentWithLegendLayout {\n legend: Dimensions & {\n show: boolean;\n };\n content: Dimensions;\n margin: {\n right: number;\n bottom: number;\n };\n}\n\ntype LegendSizeConfig = Record<LegendSize, Record<LegendPositions, number>>;\n\nexport const TABLE_LEGEND_SIZE: LegendSizeConfig = {\n medium: {\n // 5 rows plus header. Value to be multiplied by row height in pixels.\n bottom: 6,\n\n // Pixel value\n right: 250,\n },\n small: {\n // 3 rows plus header. Value to be multiplied by row height in pixels.\n bottom: 4,\n\n // Pixel value\n right: 150,\n },\n};\n\nconst PANEL_HEIGHT_LG_BREAKPOINT = 300;\nconst LEGEND_HEIGHT_SM = 40;\nconst LEGEND_HEIGHT_LG = 100;\n\n/**\n * Returns information for laying out content alongside a legend.\n */\nexport function getContentWithLegendLayout({\n width,\n height,\n legendProps,\n legendSize,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n}: ContentWithLegendLayoutOpts): ContentWithLegendLayout {\n const legendOptions = legendProps?.options;\n const hasLegend = !!legendOptions;\n\n const noLegendLayout: ContentWithLegendLayout = {\n legend: {\n show: false,\n width: 0,\n height: 0,\n },\n content: {\n width,\n height,\n },\n margin: {\n right: 0,\n bottom: 0,\n },\n };\n\n if (!hasLegend) {\n return noLegendLayout;\n }\n\n const { position } = legendOptions;\n const mode = getLegendMode(legendOptions.mode);\n\n let legendWidth;\n let legendHeight;\n\n if (mode === 'list') {\n // TODO: normalize list to share similar height options as the table\n // when we add more size options.\n legendWidth = position === 'right' ? 200 : width;\n\n // TODO: account for number of legend items returned when adjusting legend spacing\n legendHeight = LEGEND_HEIGHT_SM;\n if (position === 'right') {\n legendHeight = height;\n } else if (height >= PANEL_HEIGHT_LG_BREAKPOINT) {\n legendHeight = LEGEND_HEIGHT_LG;\n }\n } else {\n // Table mode\n\n const tableLayout = getTableCellLayout(theme, 'compact');\n\n const tableColumns = legendProps?.tableProps?.columns || [];\n const columnsWidth = tableColumns.reduce((total, col) => {\n if (typeof col.width === 'number') {\n total += col.width;\n }\n return total;\n }, 0);\n\n legendWidth = position === 'right' ? TABLE_LEGEND_SIZE[legendSize]['right'] + columnsWidth : width;\n\n // Use the smaller of the size-based row count or the number of legend items + 1 for the header.\n const rowsToShow = Math.min(TABLE_LEGEND_SIZE[legendSize]['bottom'], legendProps.data.length + 1);\n legendHeight = position === 'bottom' ? rowsToShow * tableLayout.height : height;\n }\n\n const contentWidth = position === 'right' ? width - legendWidth - spacing : width;\n const contentHeight = position === 'bottom' ? height - legendHeight - spacing : height;\n\n if (\n (position === 'right' && contentWidth < minChildrenWidth) ||\n (position === 'bottom' && contentHeight < minChildrenHeight)\n ) {\n // Legend does not fit. Just show the content.\n return noLegendLayout;\n }\n\n return {\n legend: {\n width: legendWidth,\n height: legendHeight,\n show: true,\n },\n content: {\n width: contentWidth,\n height: contentHeight,\n },\n margin: {\n right: position === 'right' ? spacing : 0,\n bottom: position === 'bottom' ? spacing : 0,\n },\n };\n}\n"],"names":["getLegendMode","getTableCellLayout","TABLE_LEGEND_SIZE","medium","bottom","right","small","PANEL_HEIGHT_LG_BREAKPOINT","LEGEND_HEIGHT_SM","LEGEND_HEIGHT_LG","getContentWithLegendLayout","width","height","legendProps","legendSize","minChildrenHeight","minChildrenWidth","spacing","theme","legendOptions","options","hasLegend","noLegendLayout","legend","show","content","margin","position","mode","legendWidth","legendHeight","tableLayout","tableColumns","tableProps","columns","columnsWidth","reduce","total","col","rowsToShow","Math","min","data","length","contentWidth","contentHeight"],"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,SAA0BA,aAAa,QAAoB,cAAc;AAEzE,SAASC,kBAAkB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3B,KAAK;YACpB;YACA,OAAO0B;QACT,GAAG;QAEHR,cAAcF,aAAa,UAAUzB,iBAAiB,CAACY,WAAW,CAAC,QAAQ,GAAGqB,eAAexB;QAE7F,gGAAgG;QAChG,MAAM4B,aAAaC,KAAKC,GAAG,CAACvC,iBAAiB,CAACY,WAAW,CAAC,SAAS,EAAED,YAAY6B,IAAI,CAACC,MAAM,GAAG;QAC/Fb,eAAeH,aAAa,WAAWY,aAAaR,YAAYnB,MAAM,GAAGA;IAC3E;IAEA,MAAMgC,eAAejB,aAAa,UAAUhB,QAAQkB,cAAcZ,UAAUN;IAC5E,MAAMkC,gBAAgBlB,aAAa,WAAWf,SAASkB,eAAeb,UAAUL;IAEhF,IACE,AAACe,aAAa,WAAWiB,eAAe5B,oBACvCW,aAAa,YAAYkB,gBAAgB9B,mBAC1C;QACA,8CAA8C;QAC9C,OAAOO;IACT;IAEA,OAAO;QACLC,QAAQ;YACNZ,OAAOkB;YACPjB,QAAQkB;YACRN,MAAM;QACR;QACAC,SAAS;YACPd,OAAOiC;YACPhC,QAAQiC;QACV;QACAnB,QAAQ;YACNrB,OAAOsB,aAAa,UAAUV,UAAU;YACxCb,QAAQuB,aAAa,WAAWV,UAAU;QAC5C;IACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { StackProps } from '@mui/material';
2
2
  import { ReactElement } from 'react';
3
- import { Action } from '@perses-dev/core';
3
+ import { Action } from '@perses-dev/components';
4
4
  export interface FormActionsProps extends StackProps {
5
5
  action: Action;
6
6
  submitText?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../src/FormEditor/FormActions.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,UAAU,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,WAAW,gBAAiB,SAAQ,UAAU;I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W,CAAC,EAC1B,MAAM,EACN,UAAmB,EACnB,UAAqB,EACrB,UAAU,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,gBAAgB,GAAG,YAAY,CAkDjC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/FormEditor/FormActions.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 { Button, Divider, Stack, StackProps } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { Action } from '@perses-dev/core';\n\nexport interface FormActionsProps extends StackProps {\n action: Action;\n submitText?: string;\n cancelText?: string;\n isReadonly?: boolean;\n isValid?: boolean;\n onActionChange?: (action: Action) => void;\n onSubmit?: () => void;\n onDelete?: () => void;\n onCancel?: () => void;\n}\n\nexport function FormActions({\n action,\n submitText = 'Save',\n cancelText = 'Cancel',\n isReadonly,\n isValid,\n onActionChange,\n onSubmit,\n onDelete,\n onCancel,\n ...props\n}: FormActionsProps): ReactElement {\n return (\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }} {...props}>\n {action === 'read' ? (\n <>\n {onActionChange && (\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => onActionChange('update')}>\n Edit\n </Button>\n )}\n {onDelete && (\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n )}\n {onCancel && (onSubmit || onDelete) && (\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={{\n borderColor: (theme) => theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n }}\n />\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n ) : (\n <>\n {onSubmit && (\n <Button variant=\"contained\" disabled={!isValid} onClick={onSubmit}>\n {submitText}\n </Button>\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["Button","Divider","Stack","FormActions","action","submitText","cancelText","isReadonly","isValid","onActionChange","onSubmit","onDelete","onCancel","props","direction","gap","sx","marginLeft","disabled","variant","onClick","color","orientation","flexItem","borderColor","theme","palette","grey","marginRight"],"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,EAAEC,OAAO,EAAEC,KAAK,QAAoB,gBAAgB;AAgBnE,OAAO,SAASC,YAAY,EAC1BC,MAAM,EACNC,aAAa,MAAM,EACnBC,aAAa,QAAQ,EACrBC,UAAU,EACVC,OAAO,EACPC,cAAc,EACdC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACR,GAAGC,OACc;IACjB,qBACE,KAACX;QAAMY,WAAU;QAAMC,KAAK;QAAGC,IAAI;YAAEC,YAAY;QAAO;QAAI,GAAGJ,KAAK;kBACjET,WAAW,uBACV;;gBACGK,gCACC,KAACT;oBAAOkB,UAAUX;oBAAYY,SAAQ;oBAAYC,SAAS,IAAMX,eAAe;8BAAW;;gBAI5FE,0BACC,KAACX;oBAAOqB,OAAM;oBAAQH,UAAUX;oBAAYY,SAAQ;oBAAWC,SAAST;8BAAU;;gBAInFC,YAAaF,CAAAA,YAAYC,QAAO,mBAC/B,KAACV;oBACCqB,aAAY;oBACZC,QAAQ;oBACRP,IAAI;wBACFQ,aAAa,CAACC,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;wBACjD,qBAAqB;4BACnBV,YAAY;4BACZW,aAAa;wBACf;oBACF;;gBAGHhB,0BACC,KAACZ;oBAAOqB,OAAM;oBAAYF,SAAQ;oBAAWC,SAASR;8BACnDN;;;2BAKP;;gBACGI,0BACC,KAACV;oBAAOmB,SAAQ;oBAAYD,UAAU,CAACV;oBAASY,SAASV;8BACtDL;;gBAGJO,0BACC,KAACZ;oBAAOqB,OAAM;oBAAYF,SAAQ;oBAAWC,SAASR;8BACnDN;;;;;AAOf"}
1
+ {"version":3,"sources":["../../src/FormEditor/FormActions.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 { Button, Divider, Stack, StackProps } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { Action } from '@perses-dev/components'; // TODO the internal permission system of Perses should not be in a shared library\n\nexport interface FormActionsProps extends StackProps {\n action: Action;\n submitText?: string;\n cancelText?: string;\n isReadonly?: boolean;\n isValid?: boolean;\n onActionChange?: (action: Action) => void;\n onSubmit?: () => void;\n onDelete?: () => void;\n onCancel?: () => void;\n}\n\nexport function FormActions({\n action,\n submitText = 'Save',\n cancelText = 'Cancel',\n isReadonly,\n isValid,\n onActionChange,\n onSubmit,\n onDelete,\n onCancel,\n ...props\n}: FormActionsProps): ReactElement {\n return (\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }} {...props}>\n {action === 'read' ? (\n <>\n {onActionChange && (\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => onActionChange('update')}>\n Edit\n </Button>\n )}\n {onDelete && (\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n )}\n {onCancel && (onSubmit || onDelete) && (\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={{\n borderColor: (theme) => theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n }}\n />\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n ) : (\n <>\n {onSubmit && (\n <Button variant=\"contained\" disabled={!isValid} onClick={onSubmit}>\n {submitText}\n </Button>\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["Button","Divider","Stack","FormActions","action","submitText","cancelText","isReadonly","isValid","onActionChange","onSubmit","onDelete","onCancel","props","direction","gap","sx","marginLeft","disabled","variant","onClick","color","orientation","flexItem","borderColor","theme","palette","grey","marginRight"],"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,EAAEC,OAAO,EAAEC,KAAK,QAAoB,gBAAgB;AAgBnE,OAAO,SAASC,YAAY,EAC1BC,MAAM,EACNC,aAAa,MAAM,EACnBC,aAAa,QAAQ,EACrBC,UAAU,EACVC,OAAO,EACPC,cAAc,EACdC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACR,GAAGC,OACc;IACjB,qBACE,KAACX;QAAMY,WAAU;QAAMC,KAAK;QAAGC,IAAI;YAAEC,YAAY;QAAO;QAAI,GAAGJ,KAAK;kBACjET,WAAW,uBACV;;gBACGK,gCACC,KAACT;oBAAOkB,UAAUX;oBAAYY,SAAQ;oBAAYC,SAAS,IAAMX,eAAe;8BAAW;;gBAI5FE,0BACC,KAACX;oBAAOqB,OAAM;oBAAQH,UAAUX;oBAAYY,SAAQ;oBAAWC,SAAST;8BAAU;;gBAInFC,YAAaF,CAAAA,YAAYC,QAAO,mBAC/B,KAACV;oBACCqB,aAAY;oBACZC,QAAQ;oBACRP,IAAI;wBACFQ,aAAa,CAACC,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;wBACjD,qBAAqB;4BACnBV,YAAY;4BACZW,aAAa;wBACf;oBACF;;gBAGHhB,0BACC,KAACZ;oBAAOqB,OAAM;oBAAYF,SAAQ;oBAAWC,SAASR;8BACnDN;;;2BAKP;;gBACGI,0BACC,KAACV;oBAAOmB,SAAQ;oBAAYD,UAAU,CAACV;oBAASY,SAASV;8BACtDL;;gBAGJO,0BACC,KAACZ;oBAAOqB,OAAM;oBAAYF,SAAQ;oBAAWC,SAASR;8BACnDN;;;;;AAOf"}
@@ -1,5 +1,5 @@
1
- import { FormatOptions } from '@perses-dev/core';
2
1
  import { ReactElement } from 'react';
2
+ import { FormatOptions } from '../model';
3
3
  export interface FormatControlsProps {
4
4
  value: FormatOptions;
5
5
  onChange: (unit: FormatOptions) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"FormatControls.d.ts","sourceRoot":"","sources":["../../src/FormatControls/FormatControls.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAuE,MAAM,kBAAkB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAKrC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiBD,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAgB,EAAE,EAAE,mBAAmB,GAAG,YAAY,CA+DvG"}
1
+ {"version":3,"file":"FormatControls.d.ts","sourceRoot":"","sources":["../../src/FormatControls/FormatControls.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAuE,MAAM,UAAU,CAAC;AAG9G,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiBD,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAgB,EAAE,EAAE,mBAAmB,GAAG,YAAY,CA+DvG"}
@@ -12,9 +12,9 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { Switch } from '@mui/material';
15
- import { isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues } from '@perses-dev/core';
16
15
  import { OptionsEditorControl } from '../OptionsEditorLayout';
17
16
  import { SettingsAutocomplete } from '../SettingsAutocomplete';
17
+ import { isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues } from '../model';
18
18
  import { UnitSelector } from './UnitSelector';
19
19
  const DECIMAL_PLACES_OPTIONS = [
20
20
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/FormatControls/FormatControls.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.\nimport { Switch, SwitchProps } from '@mui/material';\nimport { FormatOptions, isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues } from '@perses-dev/core';\nimport { ReactElement } from 'react';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\nimport { UnitSelector } from './UnitSelector';\n\nexport interface FormatControlsProps {\n value: FormatOptions;\n onChange: (unit: FormatOptions) => void;\n disabled?: boolean;\n}\n\nconst DECIMAL_PLACES_OPTIONS: Array<{ id: string; label: string; decimalPlaces?: number }> = [\n { id: 'default', label: 'Default', decimalPlaces: undefined },\n { id: '0', label: '0', decimalPlaces: 0 },\n { id: '1', label: '1', decimalPlaces: 1 },\n { id: '2', label: '2', decimalPlaces: 2 },\n { id: '3', label: '3', decimalPlaces: 3 },\n { id: '4', label: '4', decimalPlaces: 4 },\n];\n\nfunction getOptionByDecimalPlaces(\n decimalPlaces?: number\n): { id: string; label: string; decimalPlaces?: number } | undefined {\n return DECIMAL_PLACES_OPTIONS.find((o) => o.decimalPlaces === decimalPlaces);\n}\n\nexport function FormatControls({ value, onChange, disabled = false }: FormatControlsProps): ReactElement {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasShortValues = isUnitWithShortValues(value);\n\n const handleUnitChange = (newValue: FormatOptions | undefined): void => {\n onChange(newValue || { unit: 'decimal' }); // Fallback to 'decimal' if undefined\n };\n\n const handleDecimalPlacesChange = ({\n decimalPlaces,\n }: {\n id: string;\n label: string;\n decimalPlaces?: number;\n }): void => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimalPlaces: decimalPlaces,\n });\n }\n };\n\n const handleShortValuesChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasShortValues) {\n onChange({\n ...value,\n shortValues: checked,\n });\n }\n };\n\n return (\n <>\n <OptionsEditorControl\n label=\"Short values\"\n control={\n <Switch\n checked={hasShortValues ? shouldShortenValues(value.shortValues) : false}\n onChange={handleShortValuesChange}\n disabled={!hasShortValues}\n />\n }\n />\n <OptionsEditorControl\n label=\"Unit\"\n control={<UnitSelector value={value} onChange={handleUnitChange} disabled={disabled} />}\n />\n <OptionsEditorControl\n label=\"Decimals\"\n control={\n <SettingsAutocomplete\n value={getOptionByDecimalPlaces(value.decimalPlaces)}\n options={DECIMAL_PLACES_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={(_, value) => handleDecimalPlacesChange(value)}\n disabled={!hasDecimalPlaces}\n disableClearable\n />\n }\n />\n </>\n );\n}\n"],"names":["Switch","isUnitWithDecimalPlaces","isUnitWithShortValues","shouldShortenValues","OptionsEditorControl","SettingsAutocomplete","UnitSelector","DECIMAL_PLACES_OPTIONS","id","label","decimalPlaces","undefined","getOptionByDecimalPlaces","find","o","FormatControls","value","onChange","disabled","hasDecimalPlaces","hasShortValues","handleUnitChange","newValue","unit","handleDecimalPlacesChange","handleShortValuesChange","_","checked","shortValues","control","options","getOptionLabel","disableClearable"],"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;;AACjC,SAASA,MAAM,QAAqB,gBAAgB;AACpD,SAAwBC,uBAAuB,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ,mBAAmB;AAEtH,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,SAASC,YAAY,QAAQ,iBAAiB;AAQ9C,MAAMC,yBAAuF;IAC3F;QAAEC,IAAI;QAAWC,OAAO;QAAWC,eAAeC;IAAU;IAC5D;QAAEH,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;CACzC;AAED,SAASE,yBACPF,aAAsB;IAEtB,OAAOH,uBAAuBM,IAAI,CAAC,CAACC,IAAMA,EAAEJ,aAAa,KAAKA;AAChE;AAEA,OAAO,SAASK,eAAe,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,KAAK,EAAuB;IACvF,MAAMC,mBAAmBlB,wBAAwBe;IACjD,MAAMI,iBAAiBlB,sBAAsBc;IAE7C,MAAMK,mBAAmB,CAACC;QACxBL,SAASK,YAAY;YAAEC,MAAM;QAAU,IAAI,qCAAqC;IAClF;IAEA,MAAMC,4BAA4B,CAAC,EACjCd,aAAa,EAKd;QACC,IAAIS,kBAAkB;YACpBF,SAAS;gBACP,GAAGD,KAAK;gBACRN,eAAeA;YACjB;QACF;IACF;IAEA,MAAMe,0BAAmD,CAACC,GAAYC;QACpE,IAAIP,gBAAgB;YAClBH,SAAS;gBACP,GAAGD,KAAK;gBACRY,aAAaD;YACf;QACF;IACF;IAEA,qBACE;;0BACE,KAACvB;gBACCK,OAAM;gBACNoB,uBACE,KAAC7B;oBACC2B,SAASP,iBAAiBjB,oBAAoBa,MAAMY,WAAW,IAAI;oBACnEX,UAAUQ;oBACVP,UAAU,CAACE;;;0BAIjB,KAAChB;gBACCK,OAAM;gBACNoB,uBAAS,KAACvB;oBAAaU,OAAOA;oBAAOC,UAAUI;oBAAkBH,UAAUA;;;0BAE7E,KAACd;gBACCK,OAAM;gBACNoB,uBACE,KAACxB;oBACCW,OAAOJ,yBAAyBI,MAAMN,aAAa;oBACnDoB,SAASvB;oBACTwB,gBAAgB,CAACjB,IAAMA,EAAEL,KAAK;oBAC9BQ,UAAU,CAACS,GAAGV,QAAUQ,0BAA0BR;oBAClDE,UAAU,CAACC;oBACXa,gBAAgB;;;;;AAM5B"}
1
+ {"version":3,"sources":["../../src/FormatControls/FormatControls.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.\nimport { Switch, SwitchProps } from '@mui/material';\n\nimport { ReactElement } from 'react';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\nimport { FormatOptions, isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues } from '../model';\nimport { UnitSelector } from './UnitSelector';\n\nexport interface FormatControlsProps {\n value: FormatOptions;\n onChange: (unit: FormatOptions) => void;\n disabled?: boolean;\n}\n\nconst DECIMAL_PLACES_OPTIONS: Array<{ id: string; label: string; decimalPlaces?: number }> = [\n { id: 'default', label: 'Default', decimalPlaces: undefined },\n { id: '0', label: '0', decimalPlaces: 0 },\n { id: '1', label: '1', decimalPlaces: 1 },\n { id: '2', label: '2', decimalPlaces: 2 },\n { id: '3', label: '3', decimalPlaces: 3 },\n { id: '4', label: '4', decimalPlaces: 4 },\n];\n\nfunction getOptionByDecimalPlaces(\n decimalPlaces?: number\n): { id: string; label: string; decimalPlaces?: number } | undefined {\n return DECIMAL_PLACES_OPTIONS.find((o) => o.decimalPlaces === decimalPlaces);\n}\n\nexport function FormatControls({ value, onChange, disabled = false }: FormatControlsProps): ReactElement {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasShortValues = isUnitWithShortValues(value);\n\n const handleUnitChange = (newValue: FormatOptions | undefined): void => {\n onChange(newValue || { unit: 'decimal' }); // Fallback to 'decimal' if undefined\n };\n\n const handleDecimalPlacesChange = ({\n decimalPlaces,\n }: {\n id: string;\n label: string;\n decimalPlaces?: number;\n }): void => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimalPlaces: decimalPlaces,\n });\n }\n };\n\n const handleShortValuesChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasShortValues) {\n onChange({\n ...value,\n shortValues: checked,\n });\n }\n };\n\n return (\n <>\n <OptionsEditorControl\n label=\"Short values\"\n control={\n <Switch\n checked={hasShortValues ? shouldShortenValues(value.shortValues) : false}\n onChange={handleShortValuesChange}\n disabled={!hasShortValues}\n />\n }\n />\n <OptionsEditorControl\n label=\"Unit\"\n control={<UnitSelector value={value} onChange={handleUnitChange} disabled={disabled} />}\n />\n <OptionsEditorControl\n label=\"Decimals\"\n control={\n <SettingsAutocomplete\n value={getOptionByDecimalPlaces(value.decimalPlaces)}\n options={DECIMAL_PLACES_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={(_, value) => handleDecimalPlacesChange(value)}\n disabled={!hasDecimalPlaces}\n disableClearable\n />\n }\n />\n </>\n );\n}\n"],"names":["Switch","OptionsEditorControl","SettingsAutocomplete","isUnitWithDecimalPlaces","isUnitWithShortValues","shouldShortenValues","UnitSelector","DECIMAL_PLACES_OPTIONS","id","label","decimalPlaces","undefined","getOptionByDecimalPlaces","find","o","FormatControls","value","onChange","disabled","hasDecimalPlaces","hasShortValues","handleUnitChange","newValue","unit","handleDecimalPlacesChange","handleShortValuesChange","_","checked","shortValues","control","options","getOptionLabel","disableClearable"],"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;;AACjC,SAASA,MAAM,QAAqB,gBAAgB;AAGpD,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,SAAwBC,uBAAuB,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ,WAAW;AAC9G,SAASC,YAAY,QAAQ,iBAAiB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,KAAC3B;oBACCc,OAAOJ,yBAAyBI,MAAMN,aAAa;oBACnDoB,SAASvB;oBACTwB,gBAAgB,CAACjB,IAAMA,EAAEL,KAAK;oBAC9BQ,UAAU,CAACS,GAAGV,QAAUQ,0BAA0BR;oBAClDE,UAAU,CAACC;oBACXa,gBAAgB;;;;;AAM5B"}
@@ -1,5 +1,5 @@
1
- import { FormatOptions } from '@perses-dev/core';
2
1
  import { ReactElement } from 'react';
2
+ import { FormatOptions } from '../model';
3
3
  export interface UnitSelectorProps {
4
4
  value?: FormatOptions;
5
5
  onChange: (format: FormatOptions | undefined) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSelector.d.ts","sourceRoot":"","sources":["../../src/FormatControls/UnitSelector.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAA2B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAGrC,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAgBD,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAgB,EAAE,GAAG,UAAU,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAqBlH"}
1
+ {"version":3,"file":"UnitSelector.d.ts","sourceRoot":"","sources":["../../src/FormatControls/UnitSelector.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,aAAa,EAA2B,MAAM,UAAU,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAgBD,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAgB,EAAE,GAAG,UAAU,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAqBlH"}
@@ -11,8 +11,8 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { UNIT_CONFIG } from '@perses-dev/core';
15
14
  import { SettingsAutocomplete } from '../SettingsAutocomplete';
15
+ import { UNIT_CONFIG } from '../model';
16
16
  const KIND_OPTIONS = Object.entries(UNIT_CONFIG).map(([id, config])=>{
17
17
  return {
18
18
  ...config,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/FormatControls/UnitSelector.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 { FormatOptions, UNIT_CONFIG, UnitConfig } from '@perses-dev/core';\nimport { ReactElement } from 'react';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\n\nexport interface UnitSelectorProps {\n value?: FormatOptions;\n onChange: (format: FormatOptions | undefined) => void;\n disabled?: boolean;\n}\n\ntype AutocompleteUnitOption = UnitConfig & {\n id: NonNullable<FormatOptions['unit']>;\n};\n\nconst KIND_OPTIONS: readonly AutocompleteUnitOption[] = Object.entries(UNIT_CONFIG)\n .map<AutocompleteUnitOption>(([id, config]) => {\n return {\n ...config,\n id: id as AutocompleteUnitOption['id'],\n group: config.group || 'Decimal',\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nexport function UnitSelector({ value, onChange, disabled = false, ...otherProps }: UnitSelectorProps): ReactElement {\n const unitConfig = UNIT_CONFIG[value?.unit || 'decimal'];\n\n const handleChange = (_: unknown, newValue: AutocompleteUnitOption | null): void => {\n if (newValue === null) {\n onChange(undefined);\n } else {\n onChange({ unit: newValue.id } as FormatOptions);\n }\n };\n\n return (\n <SettingsAutocomplete<AutocompleteUnitOption, false, false>\n value={value ? { id: value.unit || 'decimal', ...unitConfig } : null}\n options={KIND_OPTIONS}\n groupBy={(option) => option.group ?? 'Decimal'}\n onChange={handleChange}\n disabled={disabled}\n {...otherProps}\n />\n );\n}\n"],"names":["UNIT_CONFIG","SettingsAutocomplete","KIND_OPTIONS","Object","entries","map","id","config","group","filter","disableSelectorOption","UnitSelector","value","onChange","disabled","otherProps","unitConfig","unit","handleChange","_","newValue","undefined","options","groupBy","option"],"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,SAAwBA,WAAW,QAAoB,mBAAmB;AAE1E,SAASC,oBAAoB,QAAQ,0BAA0B;AAY/D,MAAMC,eAAkDC,OAAOC,OAAO,CAACJ,aACpEK,GAAG,CAAyB,CAAC,CAACC,IAAIC,OAAO;IACxC,OAAO;QACL,GAAGA,MAAM;QACTD,IAAIA;QACJE,OAAOD,OAAOC,KAAK,IAAI;IACzB;AACF,GACCC,MAAM,CAAC,CAACF,SAAW,CAACA,OAAOG,qBAAqB;AAEnD,OAAO,SAASC,aAAa,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,KAAK,EAAE,GAAGC,YAA+B;IAClG,MAAMC,aAAahB,WAAW,CAACY,OAAOK,QAAQ,UAAU;IAExD,MAAMC,eAAe,CAACC,GAAYC;QAChC,IAAIA,aAAa,MAAM;YACrBP,SAASQ;QACX,OAAO;YACLR,SAAS;gBAAEI,MAAMG,SAASd,EAAE;YAAC;QAC/B;IACF;IAEA,qBACE,KAACL;QACCW,OAAOA,QAAQ;YAAEN,IAAIM,MAAMK,IAAI,IAAI;YAAW,GAAGD,UAAU;QAAC,IAAI;QAChEM,SAASpB;QACTqB,SAAS,CAACC,SAAWA,OAAOhB,KAAK,IAAI;QACrCK,UAAUK;QACVJ,UAAUA;QACT,GAAGC,UAAU;;AAGpB"}
1
+ {"version":3,"sources":["../../src/FormatControls/UnitSelector.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 { ReactElement } from 'react';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\nimport { FormatOptions, UNIT_CONFIG, UnitConfig } from '../model';\n\nexport interface UnitSelectorProps {\n value?: FormatOptions;\n onChange: (format: FormatOptions | undefined) => void;\n disabled?: boolean;\n}\n\ntype AutocompleteUnitOption = UnitConfig & {\n id: NonNullable<FormatOptions['unit']>;\n};\n\nconst KIND_OPTIONS: readonly AutocompleteUnitOption[] = Object.entries(UNIT_CONFIG)\n .map<AutocompleteUnitOption>(([id, config]) => {\n return {\n ...config,\n id: id as AutocompleteUnitOption['id'],\n group: config.group || 'Decimal',\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nexport function UnitSelector({ value, onChange, disabled = false, ...otherProps }: UnitSelectorProps): ReactElement {\n const unitConfig = UNIT_CONFIG[value?.unit || 'decimal'];\n\n const handleChange = (_: unknown, newValue: AutocompleteUnitOption | null): void => {\n if (newValue === null) {\n onChange(undefined);\n } else {\n onChange({ unit: newValue.id } as FormatOptions);\n }\n };\n\n return (\n <SettingsAutocomplete<AutocompleteUnitOption, false, false>\n value={value ? { id: value.unit || 'decimal', ...unitConfig } : null}\n options={KIND_OPTIONS}\n groupBy={(option) => option.group ?? 'Decimal'}\n onChange={handleChange}\n disabled={disabled}\n {...otherProps}\n />\n );\n}\n"],"names":["SettingsAutocomplete","UNIT_CONFIG","KIND_OPTIONS","Object","entries","map","id","config","group","filter","disableSelectorOption","UnitSelector","value","onChange","disabled","otherProps","unitConfig","unit","handleChange","_","newValue","undefined","options","groupBy","option"],"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,oBAAoB,QAAQ,0BAA0B;AAC/D,SAAwBC,WAAW,QAAoB,WAAW;AAYlE,MAAMC,eAAkDC,OAAOC,OAAO,CAACH,aACpEI,GAAG,CAAyB,CAAC,CAACC,IAAIC,OAAO;IACxC,OAAO;QACL,GAAGA,MAAM;QACTD,IAAIA;QACJE,OAAOD,OAAOC,KAAK,IAAI;IACzB;AACF,GACCC,MAAM,CAAC,CAACF,SAAW,CAACA,OAAOG,qBAAqB;AAEnD,OAAO,SAASC,aAAa,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,KAAK,EAAE,GAAGC,YAA+B;IAClG,MAAMC,aAAaf,WAAW,CAACW,OAAOK,QAAQ,UAAU;IAExD,MAAMC,eAAe,CAACC,GAAYC;QAChC,IAAIA,aAAa,MAAM;YACrBP,SAASQ;QACX,OAAO;YACLR,SAAS;gBAAEI,MAAMG,SAASd,EAAE;YAAC;QAC/B;IACF;IAEA,qBACE,KAACN;QACCY,OAAOA,QAAQ;YAAEN,IAAIM,MAAMK,IAAI,IAAI;YAAW,GAAGD,UAAU;QAAC,IAAI;QAChEM,SAASpB;QACTqB,SAAS,CAACC,SAAWA,OAAOhB,KAAK,IAAI;QACrCK,UAAUK;QACVJ,UAAUA;QACT,GAAGC,UAAU;;AAGpB"}
@@ -13,7 +13,7 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { produce } from 'immer';
16
- import { getLegendMode } from '@perses-dev/core';
16
+ import { getLegendMode } from '../model';
17
17
  import { ListLegend } from './ListLegend';
18
18
  import { CompactLegend } from './CompactLegend';
19
19
  import { TableLegend } from './TableLegend';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/Legend.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 { Box } from '@mui/material';\nimport { produce } from 'immer';\nimport { ReactElement, ReactNode } from 'react';\nimport { getLegendMode } from '@perses-dev/core';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\nimport { TableLegend, TableLegendProps } from './TableLegend';\nimport { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';\nimport { ListLegendItemProps } from './ListLegendItem';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendComponentOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n\n /**\n * Callback fired when the mouse is moved over a legend item.\n */\n onItemMouseOver?: ListLegendItemProps['onMouseOver'];\n\n /**\n * Callback fired when the mouse is moved out of a legend item.\n */\n onItemMouseOut?: ListLegendItemProps['onMouseOut'];\n\n /**\n * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({\n width,\n height,\n options,\n data,\n selectedItems,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n tableProps,\n}: LegendProps): ReactElement {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string): void => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n };\n\n let legendContent: ReactNode;\n if (mode === 'table') {\n legendContent = (\n <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} {...tableProps} />\n );\n } else if (options.position === 'right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'right') {\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n top: 0,\n right: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n bottom: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","ListLegend","CompactLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT","Legend","width","height","options","data","selectedItems","onSelectedItemsChange","onItemMouseOver","onItemMouseOut","tableProps","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","style","sx","top","right","backgroundColor","theme","palette","background","default","bottom"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,WAAW,QAA0B,gBAAgB;AAuC9D,4EAA4E;AAC5E,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,wDAAwD;AACxD,MAAMC,4BAA4B;AAElC,OAAO,SAASC,OAAO,EACrBC,KAAK,EACLC,MAAM,EACNC,O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Ae,GAAGyB,iBAAiB;YAAEZ,mBAAmBA;;IAC3E;IAEA,IAAIP,QAAQsB,QAAQ,KAAK,SAAS;QAChC,qBACE,KAAChC;YACCiC,OAAO;gBACLzB,OAAOA;gBACPC,QAAQA;YACV;YACAyB,IAAI;gBACFF,UAAU;gBACVG,KAAK;gBACLC,OAAO;gBACPC,iBAAiB,CAACC,QAAU,GAAGA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO,EAAE;YACnE;sBAECV;;IAGP;IAEA,kBAAkB;IAClB,qBACE,KAAC/B;QACCiC,OAAO;YACLzB,OAAOA;YACPC,QAAQA;QACV;QACAyB,IAAI;YACFF,UAAU;YACVU,QAAQ;YACRL,iBAAiB,CAACC,QAAU,GAAGA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO,EAAE;QACnE;kBAECV;;AAGP"}
1
+ {"version":3,"sources":["../../src/Legend/Legend.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 { Box } from '@mui/material';\nimport { produce } from 'immer';\nimport { ReactElement, ReactNode } from 'react';\nimport { getLegendMode } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\nimport { TableLegend, TableLegendProps } from './TableLegend';\nimport { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';\nimport { ListLegendItemProps } from './ListLegendItem';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendComponentOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n\n /**\n * Callback fired when the mouse is moved over a legend item.\n */\n onItemMouseOver?: ListLegendItemProps['onMouseOver'];\n\n /**\n * Callback fired when the mouse is moved out of a legend item.\n */\n onItemMouseOut?: ListLegendItemProps['onMouseOut'];\n\n /**\n * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({\n width,\n height,\n options,\n data,\n selectedItems,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n tableProps,\n}: LegendProps): ReactElement {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string): void => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n };\n\n let legendContent: ReactNode;\n if (mode === 'table') {\n legendContent = (\n <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} {...tableProps} />\n );\n } else if (options.position === 'right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'right') {\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n top: 0,\n right: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n bottom: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","ListLegend","CompactLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT","Legend","width","height","options","data","selectedItems","onSelectedItemsChange","onItemMouseOver","onItemMouseOut","tableProps","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","style","sx","top","right","backgroundColor","theme","palette","background","default","bottom"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,UAAU,QAAQ,eAAe;AAC1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AAuBA;YAAuBL,OAAOA;YAAQ,GAAGQ,UAAU;;IAElH,OAAO,IAAIN,QAAQsB,QAAQ,KAAK,WAAWL,qBAAqB;QAC9DI,8BAAgB,KAAC5B;YAAY,GAAG0B,iBAAiB;YAAErB,OAAOA;YAAOS,mBAAmBA;;IACtF,OAAO;QACLc,8BAAgB,KAAC3B;YAAe,GAAGyB,iBAAiB;YAAEZ,mBAAmBA;;IAC3E;IAEA,IAAIP,QAAQsB,QAAQ,KAAK,SAAS;QAChC,qBACE,KAAChC;YACCiC,OAAO;gBACLzB,OAAOA;gBACPC,QAAQA;YACV;YACAyB,IAAI;gBACFF,UAAU;gBACVG,KAAK;gBACLC,OAAO;gBACPC,iBAAiB,CAACC,QAAU,GAAGA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO,EAAE;YACnE;sBAECV;;IAGP;IAEA,kBAAkB;IAClB,qBACE,KAAC/B;QACCiC,OAAO;YACLzB,OAAOA;YACPC,QAAQA;QACV;QACAyB,IAAI;YACFF,UAAU;YACVU,QAAQ;YACRL,iBAAiB,CAACC,QAAU,GAAGA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO,EAAE;QACnE;kBAECV;;AAGP"}
@@ -1,5 +1,5 @@
1
1
  import { MouseEventHandler } from 'react';
2
- import { LegendOptionsBase } from '@perses-dev/core';
2
+ import { LegendOptionsBase } from '../model';
3
3
  export type LegendComponentOptions = LegendOptionsBase;
4
4
  export interface LegendItem {
5
5
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"legend-model.d.ts","sourceRoot":"","sources":["../../src/Legend/legend-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;AAEhF,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,uBAAuB,GAAG,OAAO,CAI9G"}
1
+ {"version":3,"file":"legend-model.d.ts","sourceRoot":"","sources":["../../src/Legend/legend-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAS7C,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;AAEhF,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,uBAAuB,GAAG,OAAO,CAI9G"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/legend-model.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 { MouseEventHandler } from 'react';\nimport { LegendOptionsBase } from '@perses-dev/core';\n\n// This file contains legend-related model code specific to the legend component.\n// See the `core` package for common/shared legend model code and the\n// `plugin-system` package for legend model code specific to panel plugin specs.\n\n// Note: explicitly defining different options for the legend component and\n// legend spec that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport type LegendComponentOptions = LegendOptionsBase;\n\nexport interface LegendItem {\n id: string;\n label: string;\n color: string;\n\n /**\n * Additional data for the legend item. Useful for laying out additional\n * columns when using a table legend.\n */\n data?: Record<string, unknown>;\n\n onClick?: MouseEventHandler<HTMLElement>;\n}\n\n/**\n * State of selected items in the legend.\n * - When \"ALL\", all legend items are selected, but not visually highlighted.\n * - Otherwise, it is a Record that associates legend item ids with a boolean\n * value. When the associated entry for a legend item is `true`, that item\n * will be treated as selected and visually highlighted.\n */\nexport type SelectedLegendItemState = Record<LegendItem['id'], boolean> | 'ALL';\n\nexport function isLegendItemVisuallySelected(item: LegendItem, selectedItems: SelectedLegendItemState): boolean {\n // In the \"ALL\" case, technically all legend items are selected, but we do\n // not render them differently.\n return selectedItems !== 'ALL' && !!selectedItems[item.id];\n}\n"],"names":["isLegendItemVisuallySelected","item","selectedItems","id"],"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;AAqCjC,OAAO,SAASA,6BAA6BC,IAAgB,EAAEC,aAAsC;IACnG,0EAA0E;IAC1E,+BAA+B;IAC/B,OAAOA,kBAAkB,SAAS,CAAC,CAACA,aAAa,CAACD,KAAKE,EAAE,CAAC;AAC5D"}
1
+ {"version":3,"sources":["../../src/Legend/legend-model.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 { MouseEventHandler } from 'react';\nimport { LegendOptionsBase } from '../model';\n\n// This file contains legend-related model code specific to the legend component.\n// See the `core` package for common/shared legend model code and the\n// `plugin-system` package for legend model code specific to panel plugin specs.\n\n// Note: explicitly defining different options for the legend component and\n// legend spec that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport type LegendComponentOptions = LegendOptionsBase;\n\nexport interface LegendItem {\n id: string;\n label: string;\n color: string;\n\n /**\n * Additional data for the legend item. Useful for laying out additional\n * columns when using a table legend.\n */\n data?: Record<string, unknown>;\n\n onClick?: MouseEventHandler<HTMLElement>;\n}\n\n/**\n * State of selected items in the legend.\n * - When \"ALL\", all legend items are selected, but not visually highlighted.\n * - Otherwise, it is a Record that associates legend item ids with a boolean\n * value. When the associated entry for a legend item is `true`, that item\n * will be treated as selected and visually highlighted.\n */\nexport type SelectedLegendItemState = Record<LegendItem['id'], boolean> | 'ALL';\n\nexport function isLegendItemVisuallySelected(item: LegendItem, selectedItems: SelectedLegendItemState): boolean {\n // In the \"ALL\" case, technically all legend items are selected, but we do\n // not render them differently.\n return selectedItems !== 'ALL' && !!selectedItems[item.id];\n}\n"],"names":["isLegendItemVisuallySelected","item","selectedItems","id"],"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;AAqCjC,OAAO,SAASA,6BAA6BC,IAAgB,EAAEC,aAAsC;IACnG,0EAA0E;IAC1E,+BAA+B;IAC/B,OAAOA,kBAAkB,SAAS,CAAC,CAACA,aAAa,CAACD,KAAKE,EAAE,CAAC;AAC5D"}
@@ -1,6 +1,6 @@
1
1
  import { HTMLAttributes, ReactElement } from 'react';
2
2
  import { Control } from 'react-hook-form';
3
- import { PanelEditorValues } from '@perses-dev/core';
3
+ import { PanelEditorValues } from '@perses-dev/spec';
4
4
  export interface LinksEditorProps extends HTMLAttributes<HTMLDivElement> {
5
5
  control: Control<PanelEditorValues>;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/LinksEditor/LinksEditor.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 { Fragment, HTMLAttributes, ReactElement } from 'react';\nimport { Divider, IconButton, Stack, Typography } from '@mui/material';\nimport { Controller, useFieldArray, Control } from 'react-hook-form';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport { PanelEditorValues } from '@perses-dev/core';\nimport { LinkEditorForm } from './LinkEditorForm';\n\nexport interface LinksEditorProps extends HTMLAttributes<HTMLDivElement> {\n control: Control<PanelEditorValues>;\n}\n\nexport function LinksEditor({ control, ...props }: LinksEditorProps): ReactElement {\n const { fields, append, remove } = useFieldArray({\n control: control,\n name: 'panelDefinition.spec.links',\n });\n\n return (\n <Stack {...props} gap={3}>\n {fields && fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <LinkControl control={control} index={index} />\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => remove(index)}>\n <MinusIcon />\n </IconButton>\n </Stack>\n <Divider />\n </Fragment>\n ))\n ) : (\n <Typography variant=\"subtitle1\" mb={2} fontStyle=\"italic\">\n No links defined\n </Typography>\n )}\n <IconButton\n style={{ width: 'fit-content', height: 'fit-content' }}\n onClick={() => append({ url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false })}\n >\n <PlusIcon />\n </IconButton>\n </Stack>\n );\n}\n\nfunction LinkControl({ control, index }: { control: Control<PanelEditorValues>; index: number }): ReactElement {\n const defaultLink = { url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false };\n return (\n <Controller\n control={control}\n name={`panelDefinition.spec.links.${index}`}\n render={({ field, field: { value: link }, fieldState }) => {\n const safeLink = link ?? defaultLink;\n return (\n <LinkEditorForm\n mode=\"inline\"\n url={{\n value: safeLink.url,\n label: 'URL',\n error: { hasError: !!fieldState.error, helperText: fieldState.error?.message },\n onChange: (url) => {\n field.onChange({ ...link, url });\n },\n }}\n newTabOpen={{\n value: !!safeLink.targetBlank,\n onChange: (targetBlank) => {\n field.onChange({ ...link, targetBlank });\n },\n label: 'Open in new tab',\n }}\n name={{\n value: safeLink.name ?? '',\n label: 'Name',\n onChange: (name) => {\n field.onChange({ ...link, name });\n },\n }}\n renderVariables={{\n value: !!safeLink.renderVariables,\n label: 'Render variables',\n onChange: (renderVariables) => {\n field.onChange({ ...link, renderVariables });\n },\n }}\n tooltip={{\n value: safeLink.tooltip ?? '',\n label: 'Tooltip',\n onChange: (tooltip) => {\n field.onChange({ ...link, tooltip });\n },\n }}\n />\n );\n }}\n />\n );\n}\n"],"names":["Fragment","Divider","IconButton","Stack","Typography","Controller","useFieldArray","PlusIcon","MinusIcon","LinkEditorForm","LinksEditor","control","props","fields","append","remove","name","gap","length","map","field","index","direction","alignItems","LinkControl","style","width","height","onClick","id","variant","mb","fontStyle","url","tooltip","renderVariables","targetBlank","defaultLink","render","value","link","fieldState","safeLink","mode","label","error","hasError","helperText","message","onChange","newTabOpen"],"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,QAAQ,QAAsC,QAAQ;AAC/D,SAASC,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AACvE,SAASC,UAAU,EAAEC,aAAa,QAAiB,kBAAkB;AACrE,OAAOC,cAAc,uBAAuB;AAC5C,OAAOC,eAAe,wBAAwB;AAE9C,SAASC,cAAc,QAAQ,mBAAmB;AAMlD,OAAO,SAASC,YAAY,EAAEC,OAAO,EAAE,GAAGC,OAAyB;IACjE,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGT,cAAc;QAC/CK,SAASA;QACTK,MAAM;IACR;IAEA,qBACE,MAACb;QAAO,GAAGS,KAAK;QAAEK,KAAK;;YACpBJ,UAAUA,OAAOK,MAAM,GAAG,IACzBL,OAAOM,GAAG,CAAC,CAACC,OAAOC,sBACjB,MAACrB;;sCACC,MAACG;4BAAMmB,WAAU;4BAAML,KAAK;4BAAGM,YAAW;;8CACxC,KAACC;oCAAYb,SAASA;oCAASU,OAAOA;;8CACtC,KAACnB;oCAAWuB,OAAO;wCAAEC,OAAO;wCAAeC,QAAQ;oCAAc;oCAAGC,SAAS,IAAMb,OAAOM;8CACxF,cAAA,KAACb;;;;sCAGL,KAACP;;mBAPYmB,MAAMS,EAAE,mBAWzB,KAACzB;gBAAW0B,SAAQ;gBAAYC,IAAI;gBAAGC,WAAU;0BAAS;;0BAI5D,KAAC9B;g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O;oBACPK,UAAU,CAACd;wBACTf,MAAM6B,QAAQ,CAAC;4BAAE,GAAGT,IAAI;4BAAEL;wBAAgB;oBAC5C;gBACF;gBACAD,SAAS;oBACPK,OAAOG,SAASR,OAAO,IAAI;oBAC3BU,OAAO;oBACPK,UAAU,CAACf;wBACTd,MAAM6B,QAAQ,CAAC;4BAAE,GAAGT,IAAI;4BAAEN;wBAAQ;oBACpC;gBACF;;QAGN;;AAGN"}
1
+ {"version":3,"sources":["../../src/LinksEditor/LinksEditor.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 { Fragment, HTMLAttributes, ReactElement } from 'react';\nimport { Divider, IconButton, Stack, Typography } from '@mui/material';\nimport { Controller, useFieldArray, Control } from 'react-hook-form';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport { PanelEditorValues } from '@perses-dev/spec';\nimport { LinkEditorForm } from './LinkEditorForm';\n\nexport interface LinksEditorProps extends HTMLAttributes<HTMLDivElement> {\n control: Control<PanelEditorValues>;\n}\n\nexport function LinksEditor({ control, ...props }: LinksEditorProps): ReactElement {\n const { fields, append, remove } = useFieldArray({\n control: control,\n name: 'panelDefinition.spec.links',\n });\n\n return (\n <Stack {...props} gap={3}>\n {fields && fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <LinkControl control={control} index={index} />\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => remove(index)}>\n <MinusIcon />\n </IconButton>\n </Stack>\n <Divider />\n </Fragment>\n ))\n ) : (\n <Typography variant=\"subtitle1\" mb={2} fontStyle=\"italic\">\n No links defined\n </Typography>\n )}\n <IconButton\n style={{ width: 'fit-content', height: 'fit-content' }}\n onClick={() => append({ url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false })}\n >\n <PlusIcon />\n </IconButton>\n </Stack>\n );\n}\n\nfunction LinkControl({ control, index }: { control: Control<PanelEditorValues>; index: number }): ReactElement {\n const defaultLink = { url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false };\n return (\n <Controller\n control={control}\n name={`panelDefinition.spec.links.${index}`}\n render={({ field, field: { value: link }, fieldState }) => {\n const safeLink = link ?? defaultLink;\n return (\n <LinkEditorForm\n mode=\"inline\"\n url={{\n value: safeLink.url,\n label: 'URL',\n error: { hasError: !!fieldState.error, helperText: fieldState.error?.message },\n onChange: (url) => {\n field.onChange({ ...link, url });\n },\n }}\n newTabOpen={{\n value: !!safeLink.targetBlank,\n onChange: (targetBlank) => {\n field.onChange({ ...link, targetBlank });\n },\n label: 'Open in new tab',\n }}\n name={{\n value: safeLink.name ?? '',\n label: 'Name',\n onChange: (name) => {\n field.onChange({ ...link, name });\n },\n }}\n renderVariables={{\n value: !!safeLink.renderVariables,\n label: 'Render variables',\n onChange: (renderVariables) => {\n field.onChange({ ...link, renderVariables });\n },\n }}\n tooltip={{\n value: safeLink.tooltip ?? '',\n label: 'Tooltip',\n onChange: (tooltip) => {\n field.onChange({ ...link, tooltip });\n },\n }}\n />\n );\n }}\n />\n );\n}\n"],"names":["Fragment","Divider","IconButton","Stack","Typography","Controller","useFieldArray","PlusIcon","MinusIcon","LinkEditorForm","LinksEditor","control","props","fields","append","remove","name","gap","length","map","field","index","direction","alignItems","LinkControl","style","width","height","onClick","id","variant","mb","fontStyle","url","tooltip","renderVariables","targetBlank","defaultLink","render","value","link","fieldState","safeLink","mode","label","error","hasError","helperText","message","onChange","newTabOpen"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAm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AAC;4BAAE,GAAGT,IAAI;4BAAEN;wBAAQ;oBACpC;gBACF;;QAGN;;AAGN"}
@@ -1,4 +1,4 @@
1
- import { DurationString } from '@perses-dev/core';
1
+ import { DurationString } from '@perses-dev/spec';
2
2
  import { ReactElement } from 'react';
3
3
  import { TimeOption } from '../model';
4
4
  interface RefreshIntervalPickerProps {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.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 { Box, FormControl, MenuItem, Select } from '@mui/material';\nimport { DurationString } from '@perses-dev/core';\nimport { ReactElement, useMemo } from 'react';\nimport { TimeOption } from '../model';\n\ninterface RefreshIntervalPickerProps {\n timeOptions: TimeOption[];\n value?: DurationString;\n onChange: (value: DurationString) => void;\n height?: string;\n}\n\nexport function RefreshIntervalPicker(props: RefreshIntervalPickerProps): ReactElement {\n const { value, onChange, timeOptions, height } = props;\n\n // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select\n const customInterval = useMemo(() => {\n if (value && !timeOptions.some((option) => option.value.pastDuration === value)) {\n return <MenuItem value={value}>{value}</MenuItem>;\n }\n }, [timeOptions, value]);\n\n return (\n <FormControl>\n <Box>\n <Select\n id=\"refreshInterval\"\n value={value}\n onChange={(event) => {\n const duration = event.target.value as DurationString;\n onChange(duration);\n }}\n inputProps={{\n 'aria-label': `Select refresh interval. Currently set to ${value}`,\n }}\n sx={{\n '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n {customInterval}\n </Select>\n </Box>\n </FormControl>\n );\n}\n"],"names":["Box","FormControl","MenuItem","Select","useMemo","RefreshIntervalPicker","props","value","onChange","timeOptions","height","customInterval","some","option","pastDuration","id","event","duration","target","inputProps","sx","lineHeight","paddingY","map","item","idx","display"],"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,GAAG,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,gBAAgB;AAEnE,SAAuBC,OAAO,QAAQ,QAAQ;AAU9C,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGJ;IAEjD,oHAAoH;IACpH,MAAMK,iBAAiBP,QAAQ;QAC7B,IAAIG,SAAS,CAACE,YAAYG,IAAI,CAAC,CAACC,SAAWA,OAAON,KAAK,CAACO,YAAY,KAAKP,QAAQ;YAC/E,qBAAO,KAACL;gBAASK,OAAOA;0BAAQA;;QAClC;IACF,GAAG;QAACE;QAAaF;KAAM;IAEvB,qBACE,KAACN;kBACC,cAAA,KAACD;sBACC,cAAA,MAACG;gBACCY,IAAG;gBACHR,OAAOA;gBACPC,UAAU,CAACQ;oBACT,MAAMC,WAAWD,MAAME,MAAM,CAACX,KAAK;oBACnCC,SAASS;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAEZ,OAAO;gBACpE;gBACAa,IAAI;oBACF,qBAAqBV,SAAS;wBAAEW,YAAYX;wBAAQY,UAAU;oBAAE,IAAI,CAAC;gBACvE;;oBAECb,YAAYc,GAAG,CAAC,CAACC,MAAMC,oBACtB,KAACvB;4BAAmBK,OAAOiB,KAAKjB,KAAK,CAACO,YAAY;sCAC/CU,KAAKE,OAAO;2BADAD;oBAIhBd;;;;;AAKX"}
1
+ {"version":3,"sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.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 { Box, FormControl, MenuItem, Select } from '@mui/material';\nimport { DurationString } from '@perses-dev/spec';\nimport { ReactElement, useMemo } from 'react';\nimport { TimeOption } from '../model';\n\ninterface RefreshIntervalPickerProps {\n timeOptions: TimeOption[];\n value?: DurationString;\n onChange: (value: DurationString) => void;\n height?: string;\n}\n\nexport function RefreshIntervalPicker(props: RefreshIntervalPickerProps): ReactElement {\n const { value, onChange, timeOptions, height } = props;\n\n // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select\n const customInterval = useMemo(() => {\n if (value && !timeOptions.some((option) => option.value.pastDuration === value)) {\n return <MenuItem value={value}>{value}</MenuItem>;\n }\n }, [timeOptions, value]);\n\n return (\n <FormControl>\n <Box>\n <Select\n id=\"refreshInterval\"\n value={value}\n onChange={(event) => {\n const duration = event.target.value as DurationString;\n onChange(duration);\n }}\n inputProps={{\n 'aria-label': `Select refresh interval. Currently set to ${value}`,\n }}\n sx={{\n '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n {customInterval}\n </Select>\n </Box>\n </FormControl>\n );\n}\n"],"names":["Box","FormControl","MenuItem","Select","useMemo","RefreshIntervalPicker","props","value","onChange","timeOptions","height","customInterval","some","option","pastDuration","id","event","duration","target","inputProps","sx","lineHeight","paddingY","map","item","idx","display"],"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,GAAG,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,gBAAgB;AAEnE,SAAuBC,OAAO,QAAQ,QAAQ;AAU9C,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGJ;IAEjD,oHAAoH;IACpH,MAAMK,iBAAiBP,QAAQ;QAC7B,IAAIG,SAAS,CAACE,YAAYG,IAAI,CAAC,CAACC,SAAWA,OAAON,KAAK,CAACO,YAAY,KAAKP,QAAQ;YAC/E,qBAAO,KAACL;gBAASK,OAAOA;0BAAQA;;QAClC;IACF,GAAG;QAACE;QAAaF;KAAM;IAEvB,qBACE,KAACN;kBACC,cAAA,KAACD;sBACC,cAAA,MAACG;gBACCY,IAAG;gBACHR,OAAOA;gBACPC,UAAU,CAACQ;oBACT,MAAMC,WAAWD,MAAME,MAAM,CAACX,KAAK;oBACnCC,SAASS;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAEZ,OAAO;gBACpE;gBACAa,IAAI;oBACF,qBAAqBV,SAAS;wBAAEW,YAAYX;wBAAQY,UAAU;oBAAE,IAAI,CAAC;gBACvE;;oBAECb,YAAYc,GAAG,CAAC,CAACC,MAAMC,oBACtB,KAACvB;4BAAmBK,OAAOiB,KAAKjB,KAAK,CAACO,YAAY;sCAC/CU,KAAKE,OAAO;2BADAD;oBAIhBd;;;;;AAKX"}
@@ -6,5 +6,5 @@ import { TableProps } from './model/table-model';
6
6
  *
7
7
  * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**
8
8
  */
9
- export declare function Table<TableData>({ data, columns, cellConfigs, density, defaultColumnWidth, defaultColumnHeight, checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId, rowSelection, sorting, getItemActions, hasItemActions, pagination, onPaginationChange, rowSelectionVariant, ...otherProps }: TableProps<TableData>): ReactElement;
9
+ export declare function Table<TableData>({ data, columns, cellConfigs, density, defaultColumnWidth, defaultColumnHeight, checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId, rowSelection, sorting, getItemActions, hasItemActions, pagination, onPaginationChange, rowSelectionVariant, getSubRows, hiddenColumns, tableToolbarConfig, ...otherProps }: TableProps<TableData>): ReactElement;
10
10
  //# sourceMappingURL=Table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table/Table.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAwB,UAAU,EAAkC,MAAM,qBAAqB,CAAC;AAYvG;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,EAC/B,IAAI,EACJ,OAAO,EACP,WAAW,EACX,OAAoB,EACpB,kBAAyC,EACzC,mBAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,QAA6B,EAC7B,YAAoC,EACpC,OAAyB,EACzB,cAAc,EACd,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,mBAAgC,EAChC,GAAG,UAAU,EACd,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,YAAY,CA6JtC"}
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table/Table.tsx"],"names":[],"mappings":"AA4BA,OAAO,EAAE,YAAY,EAAkC,MAAM,OAAO,CAAC;AAIrE,OAAO,EAAwD,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAYvG;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,EAC/B,IAAI,EACJ,OAAO,EACP,WAAW,EACX,OAAoB,EACpB,kBAAyC,EACzC,mBAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,QAA6B,EAC7B,YAAoC,EACpC,OAAyB,EACzB,cAAc,EACd,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,mBAAgC,EAChC,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,GAAG,UAAU,EACd,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,YAAY,CAmLtC"}
@@ -12,8 +12,9 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Stack, useTheme } from '@mui/material';
15
- import { getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
16
- import { useCallback, useMemo } from 'react';
15
+ import { getCoreRowModel, getExpandedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
16
+ import { useCallback, useMemo, useState } from 'react';
17
+ import { useFuzzySearch } from './hooks/useFuzzySearch';
17
18
  import { TableCheckbox } from './TableCheckbox';
18
19
  import { VirtualizedTable } from './VirtualizedTable';
19
20
  import { DEFAULT_COLUMN_WIDTH, persesColumnsToTanstackColumns } from './model/table-model';
@@ -30,8 +31,13 @@ const DEFAULT_SORTING = [];
30
31
  * **not** intended to be a general use data table for use cases unrelated to Perses.
31
32
  *
32
33
  * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**
33
- */ export function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = DEFAULT_COLUMN_WIDTH, defaultColumnHeight = 'auto', checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, getItemActions, hasItemActions, pagination, onPaginationChange, rowSelectionVariant = 'standard', ...otherProps }) {
34
+ */ export function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = DEFAULT_COLUMN_WIDTH, defaultColumnHeight = 'auto', checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, getItemActions, hasItemActions, pagination, onPaginationChange, rowSelectionVariant = 'standard', getSubRows, hiddenColumns, tableToolbarConfig, ...otherProps }) {
34
35
  const theme = useTheme();
36
+ const { globalFilter, setGlobalFilter, fuzzySearchOptions } = useFuzzySearch(tableToolbarConfig?.isSearchEnabled);
37
+ const [columnVisibility, setColumnVisibility] = useState(hiddenColumns?.reduce((acc, columnId)=>({
38
+ ...acc,
39
+ [columnId]: false
40
+ }), {}) ?? {});
35
41
  const handleRowSelectionChange = (rowSelectionUpdater)=>{
36
42
  const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
37
43
  onRowSelectionChange?.(newRowSelection);
@@ -138,7 +144,7 @@ const DEFAULT_SORTING = [];
138
144
  const table = useReactTable({
139
145
  data,
140
146
  columns: tableColumns,
141
- getRowId,
147
+ getRowId: getRowId,
142
148
  getCoreRowModel: getCoreRowModel(),
143
149
  getSortedRowModel: getSortedRowModel(),
144
150
  getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,
@@ -148,12 +154,18 @@ const DEFAULT_SORTING = [];
148
154
  enableRowSelection: !!checkboxSelection,
149
155
  onRowSelectionChange: handleRowSelectionChange,
150
156
  onSortingChange: handleSortingChange,
157
+ onColumnVisibilityChange: setColumnVisibility,
158
+ getSubRows: getSubRows,
159
+ getExpandedRowModel: getSubRows ? getExpandedRowModel() : undefined,
160
+ ...fuzzySearchOptions,
151
161
  // For now, defaulting to sort by descending first. We can expose the ability
152
162
  // to customize it if/when we have use cases for it.
153
163
  sortDescFirst: true,
154
164
  state: {
155
165
  rowSelection,
156
166
  sorting,
167
+ globalFilter: tableToolbarConfig?.isSearchEnabled ? globalFilter : undefined,
168
+ columnVisibility,
157
169
  ...pagination ? {
158
170
  pagination
159
171
  } : {}
@@ -174,12 +186,20 @@ const DEFAULT_SORTING = [];
174
186
  defaultColumnHeight: defaultColumnHeight,
175
187
  onRowClick: handleRowClick,
176
188
  rows: table.getRowModel().rows,
177
- columns: table.getAllFlatColumns(),
189
+ columns: table.getVisibleFlatColumns(),
178
190
  headers: table.getHeaderGroups(),
179
191
  cellConfigs: cellConfigs,
180
192
  pagination: pagination,
181
193
  onPaginationChange: onPaginationChange,
182
- rowCount: table.getRowCount()
194
+ rowCount: table.getRowCount(),
195
+ toolbarConfig: {
196
+ isSearchEnabled: tableToolbarConfig?.isSearchEnabled,
197
+ globalFilter,
198
+ onGlobalFilterChange: setGlobalFilter,
199
+ isColumnFilterEnabled: tableToolbarConfig?.isColumnFilterEnabled,
200
+ columns: table.getAllColumns(),
201
+ columnFilterMenuMaxHeight: tableToolbarConfig?.columnFilterMenuMaxHeight
202
+ }
183
203
  });
184
204
  }
185
205