@perses-dev/components 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) 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 +3 -3
  4. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.js +12 -3
  6. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  7. package/dist/EChart/EChart.d.ts +2 -1
  8. package/dist/EChart/EChart.d.ts.map +1 -1
  9. package/dist/EChart/EChart.js +15 -3
  10. package/dist/EChart/EChart.js.map +1 -1
  11. package/dist/Legend/CompactLegend.d.ts +1 -1
  12. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  13. package/dist/Legend/CompactLegend.js +1 -1
  14. package/dist/Legend/CompactLegend.js.map +1 -1
  15. package/dist/Legend/Legend.d.ts +8 -3
  16. package/dist/Legend/Legend.d.ts.map +1 -1
  17. package/dist/Legend/Legend.js +4 -3
  18. package/dist/Legend/Legend.js.map +1 -1
  19. package/dist/Legend/ListLegend.d.ts +1 -1
  20. package/dist/Legend/ListLegend.d.ts.map +1 -1
  21. package/dist/Legend/ListLegend.js +1 -1
  22. package/dist/Legend/ListLegend.js.map +1 -1
  23. package/dist/Legend/ListLegendItem.d.ts +1 -1
  24. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  25. package/dist/Legend/ListLegendItem.js.map +1 -1
  26. package/dist/Legend/TableLegend.d.ts +3 -2
  27. package/dist/Legend/TableLegend.d.ts.map +1 -1
  28. package/dist/Legend/TableLegend.js +10 -2
  29. package/dist/Legend/TableLegend.js.map +1 -1
  30. package/dist/Legend/index.d.ts +1 -0
  31. package/dist/Legend/index.d.ts.map +1 -1
  32. package/dist/Legend/index.js +1 -0
  33. package/dist/Legend/index.js.map +1 -1
  34. package/dist/Legend/legend-model.d.ts +24 -0
  35. package/dist/Legend/legend-model.d.ts.map +1 -0
  36. package/dist/{LegendOptionsEditor/index.js → Legend/legend-model.js} +6 -2
  37. package/dist/Legend/legend-model.js.map +1 -0
  38. package/dist/LineChart/LineChart.d.ts +2 -1
  39. package/dist/LineChart/LineChart.d.ts.map +1 -1
  40. package/dist/LineChart/LineChart.js +3 -2
  41. package/dist/LineChart/LineChart.js.map +1 -1
  42. package/dist/LineChart/utils.js +1 -1
  43. package/dist/LineChart/utils.js.map +1 -1
  44. package/dist/StatChart/StatChart.js +1 -1
  45. package/dist/StatChart/StatChart.js.map +1 -1
  46. package/dist/Table/Table.js +1 -1
  47. package/dist/Table/Table.js.map +1 -1
  48. package/dist/Table/TableCell.d.ts +6 -3
  49. package/dist/Table/TableCell.d.ts.map +1 -1
  50. package/dist/Table/TableCell.js +5 -2
  51. package/dist/Table/TableCell.js.map +1 -1
  52. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  53. package/dist/Table/VirtualizedTable.js +11 -5
  54. package/dist/Table/VirtualizedTable.js.map +1 -1
  55. package/dist/Table/model/table-model.d.ts +16 -2
  56. package/dist/Table/model/table-model.d.ts.map +1 -1
  57. package/dist/Table/model/table-model.js +18 -7
  58. package/dist/Table/model/table-model.js.map +1 -1
  59. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  60. package/dist/TimeSeriesTooltip/nearby-series.js +4 -2
  61. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  62. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +1 -1
  63. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +13 -4
  64. package/dist/cjs/EChart/EChart.js +22 -5
  65. package/dist/cjs/Legend/CompactLegend.js +2 -2
  66. package/dist/cjs/Legend/Legend.js +5 -4
  67. package/dist/cjs/Legend/ListLegend.js +2 -2
  68. package/dist/cjs/Legend/TableLegend.js +10 -2
  69. package/dist/cjs/Legend/index.js +1 -0
  70. package/dist/cjs/{LegendOptionsEditor/index.js → Legend/legend-model.js} +8 -11
  71. package/dist/cjs/LineChart/LineChart.js +3 -2
  72. package/dist/cjs/LineChart/utils.js +7 -2
  73. package/dist/cjs/StatChart/StatChart.js +7 -2
  74. package/dist/cjs/Table/Table.js +1 -1
  75. package/dist/cjs/Table/TableCell.js +5 -2
  76. package/dist/cjs/Table/VirtualizedTable.js +11 -5
  77. package/dist/cjs/Table/model/table-model.js +18 -7
  78. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +4 -2
  79. package/dist/cjs/index.js +0 -1
  80. package/dist/cjs/model/index.js +0 -1
  81. package/dist/cjs/utils/theme-gen.js +7 -2
  82. package/dist/index.d.ts +0 -1
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +0 -1
  85. package/dist/index.js.map +1 -1
  86. package/dist/model/graph.d.ts +1 -1
  87. package/dist/model/graph.d.ts.map +1 -1
  88. package/dist/model/graph.js.map +1 -1
  89. package/dist/model/index.d.ts +0 -1
  90. package/dist/model/index.d.ts.map +1 -1
  91. package/dist/model/index.js +0 -1
  92. package/dist/model/index.js.map +1 -1
  93. package/dist/utils/theme-gen.js +1 -1
  94. package/dist/utils/theme-gen.js.map +1 -1
  95. package/package.json +4 -4
  96. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts +0 -8
  97. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +0 -1
  98. package/dist/LegendOptionsEditor/LegendOptionsEditor.js +0 -109
  99. package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +0 -1
  100. package/dist/LegendOptionsEditor/index.d.ts +0 -2
  101. package/dist/LegendOptionsEditor/index.d.ts.map +0 -1
  102. package/dist/LegendOptionsEditor/index.js.map +0 -1
  103. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +0 -115
  104. package/dist/cjs/model/legend.js +0 -102
  105. package/dist/model/legend.d.ts +0 -36
  106. package/dist/model/legend.d.ts.map +0 -1
  107. package/dist/model/legend.js +0 -81
  108. package/dist/model/legend.js.map +0 -1
@@ -26,7 +26,7 @@ import { getContentWithLegendLayout } from './model/content-with-legend-model';
26
26
  const { content , legend , margin } = getContentWithLegendLayout({
27
27
  width,
28
28
  height,
29
- legendOptions: legendProps === null || legendProps === void 0 ? void 0 : legendProps.options,
29
+ legendProps,
30
30
  minChildrenHeight,
31
31
  minChildrenWidth,
32
32
  spacing,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ContentWithLegend/ContentWithLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport { Box, useTheme } from '@mui/material';\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 minChildrenWidth = 100,\n minChildrenHeight = 100,\n}: ContentWithLegendProps) {\n const theme = useTheme();\n const { content, legend, margin } = getContentWithLegendLayout({\n width,\n height,\n legendOptions: legendProps?.options,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n });\n\n return (\n <Box\n sx={{\n width,\n height,\n position: 'relative',\n overflow: 'hidden',\n }}\n >\n <Box\n sx={{\n width: content.width,\n height: content.height,\n marginRight: `${margin.right}px`,\n marginBottom: `${margin.bottom}px`,\n overflow: 'hidden',\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":["React","Box","useTheme","Legend","getContentWithLegendLayout","ContentWithLegend","children","legendProps","width","height","spacing","minChildrenWidth","minChildrenHeight","theme","content","legend","margin","legendOptions","options","sx","position","overflow","marginRight","right","marginBottom","bottom","show"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SAASC,GAAG,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AAC9C,SAASC,MAAM,QAAQ,WAAW,CAAC;AACnC,SAAiCC,0BAA0B,QAAQ,mCAAmC,CAAC;AAEvG;;;;;;CAMC,GACD,OAAO,SAASC,iBAAiB,CAAC,EAChCC,QAAQ,CAAA,EACRC,WAAW,CAAA,EACXC,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,OAAO,EAAG,CAAC,CAAA,EACXC,gBAAgB,EAAG,GAAG,CAAA,EACtBC,iBAAiB,EAAG,GAAG,CAAA,EACA,EAAE;IACzB,MAAMC,KAAK,GAAGX,QAAQ,EAAE,AAAC;IACzB,MAAM,EAAEY,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGZ,0BAA0B,CAAC;QAC7DI,KAAK;QACLC,MAAM;QACNQ,aAAa,EAAEV,WAAW,aAAXA,WAAW,WAAS,GAApBA,KAAAA,CAAoB,GAApBA,WAAW,CAAEW,OAAO;QACnCN,iBAAiB;QACjBD,gBAAgB;QAChBD,OAAO;QACPG,KAAK;KACN,CAAC,AAAC;IAEH,qBACE,MAACZ,GAAG;QACFkB,EAAE,EAAE;YACFX,KAAK;YACLC,MAAM;YACNW,QAAQ,EAAE,UAAU;YACpBC,QAAQ,EAAE,QAAQ;SACnB;;0BAED,KAACpB,GAAG;gBACFkB,EAAE,EAAE;oBACFX,KAAK,EAAEM,OAAO,CAACN,KAAK;oBACpBC,MAAM,EAAEK,OAAO,CAACL,MAAM;oBACtBa,WAAW,EAAE,CAAC,EAAEN,MAAM,CAACO,KAAK,CAAC,EAAE,CAAC;oBAChCC,YAAY,EAAE,CAAC,EAAER,MAAM,CAACS,MAAM,CAAC,EAAE,CAAC;oBAClCJ,QAAQ,EAAE,QAAQ;iBACnB;0BAEA,OAAOf,QAAQ,KAAK,UAAU,GAAGA,QAAQ,CAAC;oBAAEE,KAAK,EAAEM,OAAO,CAACN,KAAK;oBAAEC,MAAM,EAAEK,OAAO,CAACL,MAAM;iBAAE,CAAC,GAAGH,QAAQ;cACnG;YACLC,WAAW,IAAIQ,MAAM,CAACW,IAAI,kBAAI,KAACvB,MAAM;gBAAE,GAAGI,WAAW;gBAAEE,MAAM,EAAEM,MAAM,CAACN,MAAM;gBAAED,KAAK,EAAEO,MAAM,CAACP,KAAK;cAAI;;MAClG,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/ContentWithLegend/ContentWithLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport { Box, useTheme } from '@mui/material';\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 minChildrenWidth = 100,\n minChildrenHeight = 100,\n}: ContentWithLegendProps) {\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 });\n\n return (\n <Box\n sx={{\n width,\n height,\n position: 'relative',\n overflow: 'hidden',\n }}\n >\n <Box\n sx={{\n width: content.width,\n height: content.height,\n marginRight: `${margin.right}px`,\n marginBottom: `${margin.bottom}px`,\n overflow: 'hidden',\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":["React","Box","useTheme","Legend","getContentWithLegendLayout","ContentWithLegend","children","legendProps","width","height","spacing","minChildrenWidth","minChildrenHeight","theme","content","legend","margin","sx","position","overflow","marginRight","right","marginBottom","bottom","show"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SAASC,GAAG,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AAC9C,SAASC,MAAM,QAAQ,WAAW,CAAC;AACnC,SAAiCC,0BAA0B,QAAQ,mCAAmC,CAAC;AAEvG;;;;;;CAMC,GACD,OAAO,SAASC,iBAAiB,CAAC,EAChCC,QAAQ,CAAA,EACRC,WAAW,CAAA,EACXC,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,OAAO,EAAG,CAAC,CAAA,EACXC,gBAAgB,EAAG,GAAG,CAAA,EACtBC,iBAAiB,EAAG,GAAG,CAAA,EACA,EAAE;IACzB,MAAMC,KAAK,GAAGX,QAAQ,EAAE,AAAC;IACzB,MAAM,EAAEY,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGZ,0BAA0B,CAAC;QAC7DI,KAAK;QACLC,MAAM;QACNF,WAAW;QACXK,iBAAiB;QACjBD,gBAAgB;QAChBD,OAAO;QACPG,KAAK;KACN,CAAC,AAAC;IAEH,qBACE,MAACZ,GAAG;QACFgB,EAAE,EAAE;YACFT,KAAK;YACLC,MAAM;YACNS,QAAQ,EAAE,UAAU;YACpBC,QAAQ,EAAE,QAAQ;SACnB;;0BAED,KAAClB,GAAG;gBACFgB,EAAE,EAAE;oBACFT,KAAK,EAAEM,OAAO,CAACN,KAAK;oBACpBC,MAAM,EAAEK,OAAO,CAACL,MAAM;oBACtBW,WAAW,EAAE,CAAC,EAAEJ,MAAM,CAACK,KAAK,CAAC,EAAE,CAAC;oBAChCC,YAAY,EAAE,CAAC,EAAEN,MAAM,CAACO,MAAM,CAAC,EAAE,CAAC;oBAClCJ,QAAQ,EAAE,QAAQ;iBACnB;0BAEA,OAAOb,QAAQ,KAAK,UAAU,GAAGA,QAAQ,CAAC;oBAAEE,KAAK,EAAEM,OAAO,CAACN,KAAK;oBAAEC,MAAM,EAAEK,OAAO,CAACL,MAAM;iBAAE,CAAC,GAAGH,QAAQ;cACnG;YACLC,WAAW,IAAIQ,MAAM,CAACS,IAAI,kBAAI,KAACrB,MAAM;gBAAE,GAAGI,WAAW;gBAAEE,MAAM,EAAEM,MAAM,CAACN,MAAM;gBAAED,KAAK,EAAEO,MAAM,CAACP,KAAK;cAAI;;MAClG,CACN;AACJ,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Theme } from '@mui/material';
3
+ import { LegendPositions } from '@perses-dev/core';
3
4
  import { LegendProps } from '../../Legend';
4
- import { LegendPositions } from '../../model/legend';
5
5
  declare type Dimensions = {
6
6
  width: number;
7
7
  height: number;
@@ -45,7 +45,7 @@ export interface ContentWithLegendProps {
45
45
  minChildrenHeight?: number;
46
46
  }
47
47
  export interface ContentWithLegendLayoutOpts extends Required<Omit<ContentWithLegendProps, 'children' | 'legendProps'>> {
48
- legendOptions?: LegendProps['options'];
48
+ legendProps?: ContentWithLegendProps['legendProps'];
49
49
  theme: Theme;
50
50
  }
51
51
  export interface ContentWithLegendLayout {
@@ -63,6 +63,6 @@ export declare const TABLE_LEGEND_SIZE: LegendSizeConfig;
63
63
  /**
64
64
  * Returns information for laying out content alongside a legend.
65
65
  */
66
- export declare function getContentWithLegendLayout({ width, height, legendOptions, minChildrenHeight, minChildrenWidth, spacing, theme, }: ContentWithLegendLayoutOpts): ContentWithLegendLayout;
66
+ export declare function getContentWithLegendLayout({ width, height, legendProps, minChildrenHeight, minChildrenWidth, spacing, theme, }: ContentWithLegendLayoutOpts): ContentWithLegendLayout;
67
67
  export {};
68
68
  //# sourceMappingURL=content-with-legend-model.d.ts.map
@@ -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,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAiB,MAAM,oBAAoB,CAAC;AAEpE,aAAK,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;IACjF;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC;IACpD;;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,aAAa,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACvC,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,aAAK,gBAAgB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,iBAAiB,EAAE,gBAM/B,CAAC;AAMF;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,KAAK,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,KAAK,GACN,EAAE,2BAA2B,GAAG,uBAAuB,CA4EvD"}
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,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,aAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM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FvD"}
@@ -10,8 +10,8 @@
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
14
  import { getTableCellLayout } from '../../Table';
14
- import { getLegendMode } from '../../model/legend';
15
15
  export const TABLE_LEGEND_SIZE = {
16
16
  // 5 rows plus header. Value to be multiplied by row height in pixels.
17
17
  Bottom: 6,
@@ -23,7 +23,8 @@ const LEGEND_HEIGHT_SM = 40;
23
23
  const LEGEND_HEIGHT_LG = 100;
24
24
  /**
25
25
  * Returns information for laying out content alongside a legend.
26
- */ export function getContentWithLegendLayout({ width , height , legendOptions , minChildrenHeight , minChildrenWidth , spacing , theme }) {
26
+ */ export function getContentWithLegendLayout({ width , height , legendProps , minChildrenHeight , minChildrenWidth , spacing , theme }) {
27
+ const legendOptions = legendProps === null || legendProps === void 0 ? void 0 : legendProps.options;
27
28
  const hasLegend = !!legendOptions;
28
29
  const noLegendLayout = {
29
30
  legend: {
@@ -59,9 +60,17 @@ const LEGEND_HEIGHT_LG = 100;
59
60
  legendHeight = LEGEND_HEIGHT_LG;
60
61
  }
61
62
  } else {
63
+ var ref;
62
64
  // Table mode
63
65
  const tableLayout = getTableCellLayout(theme, 'compact');
64
- legendWidth = position === 'Right' ? TABLE_LEGEND_SIZE['Right'] : width;
66
+ const tableColumns = (legendProps === null || legendProps === void 0 ? void 0 : (ref = legendProps.tableProps) === null || ref === void 0 ? void 0 : ref.columns) || [];
67
+ const columnsWidth = tableColumns.reduce((total, col)=>{
68
+ if (typeof col.width === 'number') {
69
+ total += col.width;
70
+ }
71
+ return total;
72
+ }, 0);
73
+ legendWidth = position === 'Right' ? TABLE_LEGEND_SIZE['Right'] + columnsWidth : width;
65
74
  legendHeight = position === 'Bottom' ? TABLE_LEGEND_SIZE['Bottom'] * tableLayout.height : height;
66
75
  }
67
76
  const contentWidth = position === 'Right' ? width - legendWidth - spacing : width;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ContentWithLegend/model/content-with-legend-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { LegendProps } from '../../Legend';\nimport { getTableCellLayout } from '../../Table';\nimport { LegendPositions, getLegendMode } from '../../model/legend';\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 * 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 * 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 legendOptions?: LegendProps['options'];\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<LegendPositions, number>;\n\nexport const TABLE_LEGEND_SIZE: LegendSizeConfig = {\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\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 legendOptions,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n}: ContentWithLegendLayoutOpts): ContentWithLegendLayout {\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 legendWidth = position === 'Right' ? TABLE_LEGEND_SIZE['Right'] : width;\n legendHeight = position === 'Bottom' ? TABLE_LEGEND_SIZE['Bottom'] * 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":["getTableCellLayout","getLegendMode","TABLE_LEGEND_SIZE","Bottom","Right","PANEL_HEIGHT_LG_BREAKPOINT","LEGEND_HEIGHT_SM","LEGEND_HEIGHT_LG","getContentWithLegendLayout","width","height","legendOptions","minChildrenHeight","minChildrenWidth","spacing","theme","hasLegend","noLegendLayout","legend","show","content","margin","right","bottom","position","mode","legendWidth","legendHeight","tableLayout","contentWidth","contentHeight"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,kBAAkB,QAAQ,aAAa,CAAC;AACjD,SAA0BC,aAAa,QAAQ,oBAAoB,CAAC;AAmEpE,OAAO,MAAMC,iBAAiB,GAAqB;IACjD,sEAAsE;IACtEC,MAAM,EAAE,CAAC;IAET,cAAc;IACdC,KAAK,EAAE,GAAG;CACX,CAAC;AAEF,MAAMC,0BAA0B,GAAG,GAAG,AAAC;AACvC,MAAMC,gBAAgB,GAAG,EAAE,AAAC;AAC5B,MAAMC,gBAAgB,GAAG,GAAG,AAAC;AAE7B;;CAEC,GACD,OAAO,SAASC,0BAA0B,CAAC,EACzCC,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,aAAa,CAAA,EACbC,iBAAiB,CAAA,EACjBC,gBAAgB,CAAA,EAChBC,OAAO,CAAA,EACPC,KAAK,CAAA,EACuB,EAA2B;IACvD,MAAMC,SAAS,GAAG,CAAC,CAACL,aAAa,AAAC;IAElC,MAAMM,cAAc,GAA4B;QAC9CC,MAAM,EAAE;YACNC,IAAI,EA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IAClF,MAAMqB,aAAa,GAAGN,QAAQ,KAAK,QAAQ,GAAGd,MAAM,GAAGiB,YAAY,GAAGb,OAAO,GAAGJ,MAAM,AAAC;IAEvF,IACE,AAACc,QAAQ,KAAK,OAAO,IAAIK,YAAY,GAAGhB,gBAAgB,IACvDW,QAAQ,KAAK,QAAQ,IAAIM,aAAa,GAAGlB,iBAAiB,AAAC,EAC5D;QACA,8CAA8C;QAC9C,OAAOK,cAAc,CAAC;IACxB,CAAC;IAED,OAAO;QACLC,MAAM,EAAE;YACNT,KAAK,EAAEiB,WAAW;YAClBhB,MAAM,EAAEiB,YAAY;YACpBR,IAAI,EAAE,IAAI;SACX;QACDC,OAAO,EAAE;YACPX,KAAK,EAAEoB,YAAY;YACnBnB,MAAM,EAAEoB,aAAa;SACtB;QACDT,MAAM,EAAE;YACNC,KAAK,EAAEE,QAAQ,KAAK,OAAO,GAAGV,OAAO,GAAG,CAAC;YACzCS,MAAM,EAAEC,QAAQ,KAAK,QAAQ,GAAGV,OAAO,GAAG,CAAC;SAC5C;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/ContentWithLegend/model/content-with-legend-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { LegendPositions, getLegendMode } 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 * 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 * 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<LegendPositions, number>;\n\nexport const TABLE_LEGEND_SIZE: LegendSizeConfig = {\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\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 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['Right'] + columnsWidth : width;\n legendHeight = position === 'Bottom' ? TABLE_LEGEND_SIZE['Bottom'] * 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","Bottom","Right","PANEL_HEIGHT_LG_BREAKPOINT","LEGEND_HEIGHT_SM","LEGEND_HEIGHT_LG","getContentWithLegendLayout","width","height","legendProps","minChildrenHeight","minChildrenWidth","spacing","theme","legendOptions","options","hasLegend","noLegendLayout","legend","show","content","margin","right","bottom","position","mode","legendWidth","legendHeight","tableLayout","tableColumns","tableProps","columns","columnsWidth","reduce","total","col","contentWidth","contentHeight"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAA0BA,aAAa,QAAQ,kBAAkB,CAAC;AAElE,SAASC,kBAAkB,QAAQ,aAAa,CAAC;AAmEjD,OAAO,MAAMC,iBAAiB,GAAqB;IACjD,sEAAsE;IACtEC,MAAM,EAAE,CAAC;IAET,cAAc;IACdC,KAAK,EAAE,GAAG;CACX,CAAC;AAEF,MAAMC,0BAA0B,GAAG,GAAG,AAAC;AACvC,MAAMC,gBAAgB,GAAG,EAAE,AAAC;AAC5B,MAAMC,gBAAgB,GAAG,GAAG,AAAC;AAE7B;;CAEC,GACD,OAAO,SAASC,0BAA0B,CAAC,EACzCC,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,WAAW,CAAA,EACXC,iBAAiB,CAAA,EACjBC,gBAAgB,CAAA,EAChBC,OAAO,CAAA,EACPC,KAAK,CAAA,EACuB,EAA2B;IACvD,MAAMC,aAAa,GAAGL,WAAW,aAAXA,WAAW,WAAS,GAApBA,KAAAA,CAAoB,GAApBA,WAAW,CAAEM,OAAO,AAAC;IAC3C,MAAMC,SAAS,GAAG,CAAC,CAACF,aAAa,AAAC;IAElC,MAAMG,cAAc,GAA4B;QAC9CC,MAAM,EAAE;YACNC,IAAI,EAAE,KAAK;YACXZ,KAAK,EAAE,CAAC;YACRC,MAAM,EAAE,CAAC;SACV;QACDY,OAAO,EAAE;YACPb,KAAK;YACLC,MAAM;SACP;QACDa,MAAM,EAAE;YACNC,KAAK,EAAE,CAAC;YACRC,MAAM,EAAE,CAAC;SACV;KACF,AAAC;IAEF,IAAI,CAACP,SAAS,EAAE;QACd,OAAOC,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,E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,YAAY,GAAGzB,KAAK,CAAC;QACvFoB,YAAY,GAAGH,QAAQ,KAAK,QAAQ,GAAGxB,iBAAiB,CAAC,QAAQ,CAAC,GAAG4B,WAAW,CAACpB,MAAM,GAAGA,MAAM,CAAC;IACnG,CAAC;IAED,MAAM4B,YAAY,GAAGZ,QAAQ,KAAK,OAAO,GAAGjB,KAAK,GAAGmB,WAAW,GAAGd,OAAO,GAAGL,KAAK,AAAC;IAClF,MAAM8B,aAAa,GAAGb,QAAQ,KAAK,QAAQ,GAAGhB,MAAM,GAAGmB,YAAY,GAAGf,OAAO,GAAGJ,MAAM,AAAC;IAEvF,IACE,AAACgB,QAAQ,KAAK,OAAO,IAAIY,YAAY,GAAGzB,gBAAgB,IACvDa,QAAQ,KAAK,QAAQ,IAAIa,aAAa,GAAG3B,iBAAiB,AAAC,EAC5D;QACA,8CAA8C;QAC9C,OAAOO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO;QACLC,MAAM,EAAE;YACNX,KAAK,EAAEmB,WAAW;YAClBlB,MAAM,EAAEmB,YAAY;YACpBR,IAAI,EAAE,IAAI;SACX;QACDC,OAAO,EAAE;YACPb,KAAK,EAAE6B,YAAY;YACnB5B,MAAM,EAAE6B,aAAa;SACtB;QACDhB,MAAM,EAAE;YACNC,KAAK,EAAEE,QAAQ,KAAK,OAAO,GAAGZ,OAAO,GAAG,CAAC;YACzCW,MAAM,EAAEC,QAAQ,KAAK,QAAQ,GAAGZ,OAAO,GAAG,CAAC;SAC5C;KACF,CAAC;AACJ,CAAC"}
@@ -54,8 +54,9 @@ export interface EChartsProps<T> {
54
54
  sx?: SxProps<Theme>;
55
55
  onEvents?: OnEventsType<T>;
56
56
  _instance?: React.MutableRefObject<ECharts | undefined>;
57
+ syncGroup?: string;
57
58
  onChartInitialized?: (instance: ECharts) => void;
58
59
  }
59
- export declare const EChart: React.MemoExoticComponent<(<T>({ option, theme, renderer, sx, onEvents, _instance, onChartInitialized, }: EChartsProps<T>) => JSX.Element)>;
60
+ export declare const EChart: React.MemoExoticComponent<(<T>({ option, theme, renderer, sx, onEvents, _instance, syncGroup, onChartInitialized, }: EChartsProps<T>) => JSX.Element)>;
60
61
  export {};
61
62
  //# sourceMappingURL=EChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EChart.d.ts","sourceRoot":"","sources":["../../src/EChart/EChart.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAQ,MAAM,cAAc,CAAC;AAChE,OAAO,EAAO,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,aAAK,eAAe,CAAC,CAAC,IAAI,CACxB,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAEhC,QAAQ,CAAC,EAAE,OAAO,KACf,IAAI,CAAC;AAEV,QAAA,MAAM,WAAW,0HAUP,CAAC;AAEX,oBAAY,cAAc,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAG1D,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IAGnB,KAAK,CAAC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CAAC,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,MAAM,wJA+FjB,CAAC"}
@@ -12,9 +12,10 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import React, { useEffect, useLayoutEffect, useRef } from 'react';
15
- import { init } from 'echarts/core';
15
+ import { init, connect } from 'echarts/core';
16
16
  import { Box } from '@mui/material';
17
- import { isEqual, debounce } from 'lodash-es';
17
+ import isEqual from 'lodash/isEqual';
18
+ import debounce from 'lodash/debounce';
18
19
  const mouseEvents = [
19
20
  'click',
20
21
  'dblclick',
@@ -31,7 +32,7 @@ const batchEvents = [
31
32
  'downplay',
32
33
  'highlight'
33
34
  ];
34
- export const EChart = /*#__PURE__*/ React.memo(function EChart({ option , theme , renderer , sx , onEvents , _instance , onChartInitialized }) {
35
+ export const EChart = /*#__PURE__*/ React.memo(function EChart({ option , theme , renderer , sx , onEvents , _instance , syncGroup , onChartInitialized }) {
35
36
  const initialOption = useRef(option);
36
37
  const prevOption = useRef(option);
37
38
  const containerRef = useRef(null);
@@ -59,6 +60,17 @@ export const EChart = /*#__PURE__*/ React.memo(function EChart({ option , theme
59
60
  theme,
60
61
  renderer
61
62
  ]);
63
+ // When syncGroup is explicitly set, charts within same group share interactions such as crosshair
64
+ useEffect(()=>{
65
+ if (!chartElement.current || !syncGroup) return;
66
+ chartElement.current.group = syncGroup;
67
+ connect([
68
+ chartElement.current
69
+ ]); // more info: https://echarts.apache.org/en/api.html#echarts.connect
70
+ }, [
71
+ syncGroup,
72
+ chartElement
73
+ ]);
62
74
  // Update chart data when option changes
63
75
  useEffect(()=>{
64
76
  if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/EChart/EChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useEffect, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport { isEqual, debounce } from 'lodash-es';\nimport { EChartsTheme } from '../model';\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = (typeof mouseEvents)[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = (typeof batchEvents)[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = React.memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return () => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return () => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n // TODO: re-evaluate how this is triggered. It's technically working right\n // now because the sx prop is an object that gets re-created, but that also\n // means it runs unnecessarily some of the time and theoretically might\n // not run in some other cases. Maybe it should use a resize observer?\n useEffect(() => {\n // TODO: fix this debouncing. This likely isn't working as intended because\n // the debounced function is re-created every time this useEffect is called.\n const updateSize = debounce(\n () => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n },\n 200,\n {\n leading: true,\n }\n );\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>) {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown) {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["React","useEffect","useLayoutEffect","useRef","init","Box","isEqual","debounce","mouseEvents","batchEvents","EChart","memo","option","theme","renderer","sx","onEvents","_instance","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","leading","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO,CAAC;AAClE,SAAqCC,IAAI,QAAQ,cAAc,CAAC;AAChE,SAASC,GAAG,QAAwB,eAAe,CAAC;AACpD,SAASC,OAAO,EAAEC,QAAQ,QAAQ,WAAW,CAAC;AAwB9C,MAAMC,WAAW,GAAG;IAClB,OAAO;IACP,UAAU;IACV,WAAW;IACX,WAAW;IACX,SAAS;IACT,WAAW;IACX,UAAU;IACV,WAAW;IACX,aAAa;CACd,AAAS,AAAC;AAkCX,MAAMC,WAAW,GAAG;IAAC,UAAU;IAAE,UAAU;IAAE,WAAW;CAAC,AAAS,AAAC;AA0BnE,OAAO,MAAMC,MAAM,iBAAGV,KAAK,CAACW,IAAI,CAAC,SAASD,MAAM,CAAI,EAClDE,MAAM,CAAA,EACNC,KAAK,CAAA,EACLC,QAAQ,CAAA,EACRC,EAAE,CAAA,EACFC,QAAQ,CAAA,EACRC,SAAS,CAAA,EACTC,kBAAkB,CAAA,EACF,EAAE;IAClB,MAAMC,aAAa,GAAGhB,MAAM,CAAoBS,MAAM,CAAC,AAAC;IACxD,MAAMQ,UAAU,GAAGjB,MAAM,CAAoBS,MA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AACC,cAAc,CAACC,IAAI,CAACX,MAAM,EAAEE,SAAS,CAAC,EAAE;gBACvCF,UAA8B;YAAlD,MAAMY,WAAW,GAAGZ,CAAAA,UAA8B,GAA9BA,MAAM,CAACE,SAAS,CAAc,cAA9BF,UAA8B,cAA9BA,UAA8B,GAAI,IAAI,AAAC;YAC3D,IAAIY,WAAW,EAAE;gBACfX,SAAS,CAACC,SAAS,EAAeU,WAAW,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAASR,YAAY,CAACF,SAAoB,EAA+B;IACvE,OAAO,AAAClC,WAAW,CAAuB6C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC;AAED,SAASK,YAAY,CAACL,SAAoB,EAA+B;IACvE,OAAO,AAACjC,WAAW,CAAuB4C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC"}
1
+ {"version":3,"sources":["../../src/EChart/EChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useEffect, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init, connect } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport isEqual from 'lodash/isEqual';\nimport debounce from 'lodash/debounce';\nimport { EChartsTheme } from '../model';\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = (typeof mouseEvents)[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = (typeof batchEvents)[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n syncGroup?: string;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = React.memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n syncGroup,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return () => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // When syncGroup is explicitly set, charts within same group share interactions such as crosshair\n useEffect(() => {\n if (!chartElement.current || !syncGroup) return;\n chartElement.current.group = syncGroup;\n connect([chartElement.current]); // more info: https://echarts.apache.org/en/api.html#echarts.connect\n }, [syncGroup, chartElement]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return () => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n // TODO: re-evaluate how this is triggered. It's technically working right\n // now because the sx prop is an object that gets re-created, but that also\n // means it runs unnecessarily some of the time and theoretically might\n // not run in some other cases. Maybe it should use a resize observer?\n useEffect(() => {\n // TODO: fix this debouncing. This likely isn't working as intended because\n // the debounced function is re-created every time this useEffect is called.\n const updateSize = debounce(\n () => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n },\n 200,\n {\n leading: true,\n }\n );\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>) {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown) {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["React","useEffect","useLayoutEffect","useRef","init","connect","Box","isEqual","debounce","mouseEvents","batchEvents","EChart","memo","option","theme","renderer","sx","onEvents","_instance","syncGroup","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","group","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","leading","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE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E;gBACvCF,UAA8B;YAAlD,MAAMY,WAAW,GAAGZ,CAAAA,UAA8B,GAA9BA,MAAM,CAACE,SAAS,CAAc,cAA9BF,UAA8B,cAA9BA,UAA8B,GAAI,IAAI,AAAC;YAC3D,IAAIY,WAAW,EAAE;gBACfX,SAAS,CAACC,SAAS,EAAeU,WAAW,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAASR,YAAY,CAACF,SAAoB,EAA+B;IACvE,OAAO,AAACpC,WAAW,CAAuB+C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC;AAED,SAASK,YAAY,CAACL,SAAoB,EAA+B;IACvE,OAAO,AAACnC,WAAW,CAAuB8C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { LegendItem, SelectedLegendItemState } from '../model';
3
2
  import { ListLegendItemProps } from './ListLegendItem';
3
+ import { LegendItem, SelectedLegendItemState } from './legend-model';
4
4
  export interface CompactLegendProps {
5
5
  height: number;
6
6
  items: LegendItem[];
@@ -1 +1 @@
1
- {"version":3,"file":"CompactLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/CompactLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,kBAAkB,eAkBpG"}
1
+ {"version":3,"file":"CompactLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/CompactLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,gBAAgB,CAAC;AAEnG,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,kBAAkB,eAkBpG"}
@@ -12,8 +12,8 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
- import { isLegendItemVisuallySelected } from '../model';
16
15
  import { ListLegendItem } from './ListLegendItem';
16
+ import { isLegendItemVisuallySelected } from './legend-model';
17
17
  /**
18
18
  * CompactLegend is default and used when legend items need to show side by side
19
19
  * which corresponds to when legend.position is `bottom` with a relatively small
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/CompactLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from '../model';\nimport { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\n\nexport interface CompactLegendProps {\n height: number;\n items: LegendItem[];\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n}\n\n/**\n * CompactLegend is default and used when legend items need to show side by side\n * which corresponds to when legend.position is `bottom` with a relatively small\n * number of items. The `ListLegend` is used for cases with large numbers of items\n * because it is virtualized.\n */\nexport function CompactLegend({ height, items, selectedItems, onLegendItemClick }: CompactLegendProps) {\n return (\n <Box component=\"ul\" sx={{ width: '100%', height, padding: [0, 1, 0, 0], overflowY: 'scroll', margin: 0 }}>\n {items.map((item) => (\n <ListLegendItem\n key={item.id}\n item={item}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n sx={{\n width: 'auto',\n float: 'left',\n paddingRight: 1.5,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","isLegendItemVisuallySelected","ListLegendItem","CompactLegend","height","items","selectedItems","onLegendItemClick","component","sx","width","padding","overflowY","margin","map","item","isVisuallySelected","onClick","float","paddingRight","id"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAA8CC,4BAA4B,QAAQ,UAAU,CAAC;AAC7F,SAASC,cAAc,QAA6B,kBAAkB,CAAC;AASvE;;;;;CAKC,GACD,OAAO,SAASC,aAAa,CAAC,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAEC,aAAa,CAAA,EAAEC,iBAAiB,CAAA,EAAsB,EAAE;IACrG,qBACE,KAACP,GAAG;QAACQ,SAAS,EAAC,IAAI;QAACC,EAAE,EAAE;YAAEC,KAAK,EAAE,MAAM;YAAEN,MAAM;YAAEO,OAAO,EAAE;AAAC,iBAAC;AAAE,iBAAC;AAAE,iBAAC;AAAE,iBAAC;aAAC;YAAEC,SAAS,EAAE,QAAQ;YAAEC,MAAM,EAAE,CAAC;SAAE;kBACrGR,KAAK,CAACS,GAAG,CAAC,CAACC,IAAI,iBACd,KAACb,cAAc;gBAEba,IAAI,EAAEA,IAAI;gBACVC,kBAAkB,EAAEf,4BAA4B,CAACc,IAAI,EAAET,aAAa,CAAC;gBACrEW,OAAO,EAAEV,iBAAiB;gBAC1BE,EAAE,EAAE;oBACFC,KAAK,EAAE,MAAM;oBACbQ,KAAK,EAAE,MAAM;oBACbC,YAAY,EAAE,GAAG;iBAClB;eARIJ,IAAI,CAACK,EAAE,CASZ,AACH,CAAC;MACE,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/CompactLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\nimport { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from './legend-model';\n\nexport interface CompactLegendProps {\n height: number;\n items: LegendItem[];\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n}\n\n/**\n * CompactLegend is default and used when legend items need to show side by side\n * which corresponds to when legend.position is `bottom` with a relatively small\n * number of items. The `ListLegend` is used for cases with large numbers of items\n * because it is virtualized.\n */\nexport function CompactLegend({ height, items, selectedItems, onLegendItemClick }: CompactLegendProps) {\n return (\n <Box component=\"ul\" sx={{ width: '100%', height, padding: [0, 1, 0, 0], overflowY: 'scroll', margin: 0 }}>\n {items.map((item) => (\n <ListLegendItem\n key={item.id}\n item={item}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n sx={{\n width: 'auto',\n float: 'left',\n paddingRight: 1.5,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ListLegendItem","isLegendItemVisuallySelected","CompactLegend","height","items","selectedItems","onLegendItemClick","component","sx","width","padding","overflowY","margin","map","item","isVisuallySelected","onClick","float","paddingRight","id"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,cAAc,QAA6B,kBAAkB,CAAC;AACvE,SAA8CC,4BAA4B,QAAQ,gBAAgB,CAAC;AASnG;;;;;CAKC,GACD,OAAO,SAASC,aAAa,CAAC,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAEC,aAAa,CAAA,EAAEC,iBAAiB,CAAA,EAAsB,EAAE;IACrG,qBACE,KAACP,GAAG;QAACQ,SAAS,EAAC,IAAI;QAACC,EAAE,EAAE;YAAEC,KAAK,EAAE,MAAM;YAAEN,MAAM;YAAEO,OAAO,EAAE;AAAC,iBAAC;AAAE,iBAAC;AAAE,iBAAC;AAAE,iBAAC;aAAC;YAAEC,SAAS,EAAE,QAAQ;YAAEC,MAAM,EAAE,CAAC;SAAE;kBACrGR,KAAK,CAACS,GAAG,CAAC,CAACC,IAAI,iBACd,KAACd,cAAc;gBAEbc,IAAI,EAAEA,IAAI;gBACVC,kBAAkB,EAAEd,4BAA4B,CAACa,IAAI,EAAET,aAAa,CAAC;gBACrEW,OAAO,EAAEV,iBAAiB;gBAC1BE,EAAE,EAAE;oBACFC,KAAK,EAAE,MAAM;oBACbQ,KAAK,EAAE,MAAM;oBACbC,YAAY,EAAE,GAAG;iBAClB;eARIJ,IAAI,CAACK,EAAE,CASZ,AACH,CAAC;MACE,CACN;AACJ,CAAC"}
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { LegendOptions, LegendItem, SelectedLegendItemState } from '../model';
2
+ import { TableLegendProps } from './TableLegend';
3
+ import { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';
3
4
  export interface LegendProps {
4
5
  width: number;
5
6
  height: number;
6
7
  data: LegendItem[];
7
- options: LegendOptions;
8
+ options: LegendComponentOptions;
8
9
  /**
9
10
  * State of selected items in the legend.
10
11
  *
@@ -16,6 +17,10 @@ export interface LegendProps {
16
17
  * Callback fired when the selected items in the legend changes.
17
18
  */
18
19
  onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;
20
+ /**
21
+ * Props specific to legend with `mode` set to `table`.
22
+ */
23
+ tableProps?: Pick<TableLegendProps, 'columns'>;
19
24
  }
20
- export declare function Legend({ width, height, options, data, selectedItems, onSelectedItemsChange }: LegendProps): JSX.Element;
25
+ export declare function Legend({ width, height, options, data, selectedItems, onSelectedItemsChange, tableProps, }: LegendProps): JSX.Element;
21
26
  //# sourceMappingURL=Legend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,uBAAuB,EAAiB,MAAM,UAAU,CAAC;AAK7F,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IAEvB;;;;;OAKG;IACH,aAAa,EAAE,uBAAuB,CAAC;IAEvC;;OAEG;IACH,qBAAqB,EAAE,CAAC,WAAW,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACvE;AASD,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,qBAAqB,EAAE,EAAE,WAAW,eA0FzG"}
1
+ {"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE7F,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,sBAAsB,CAAC;IAEhC;;;;;OAKG;IACH,aAAa,EAAE,uBAAuB,CAAC;IAEvC;;OAEG;IACH,qBAAqB,EAAE,CAAC,WAAW,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAEtE;;OAEG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;CAChD;AASD,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,MAAM,EACN,OAAO,EACP,IAAI,EACJ,aAAa,EACb,qBAAqB,EACrB,UAAU,GACX,EAAE,WAAW,eA4Fb"}
@@ -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 '../model';
16
+ import { getLegendMode } from '@perses-dev/core';
17
17
  import { ListLegend } from './ListLegend';
18
18
  import { CompactLegend } from './CompactLegend';
19
19
  import { TableLegend } from './TableLegend';
@@ -23,7 +23,7 @@ import { TableLegend } from './TableLegend';
23
23
  // Set this number based on testing, but it may need to be tuned a bit on the
24
24
  // future as people test this out on different machines.
25
25
  const NEED_VIRTUALIZATION_LIMIT = 500;
26
- export function Legend({ width , height , options , data , selectedItems , onSelectedItemsChange }) {
26
+ export function Legend({ width , height , options , data , selectedItems , onSelectedItemsChange , tableProps }) {
27
27
  const onLegendItemClick = (e, seriesId)=>{
28
28
  const isModifiedClick = e.metaKey || e.shiftKey;
29
29
  const newSelected = produce(selectedItems, (draft)=>{
@@ -73,7 +73,8 @@ export function Legend({ width , height , options , data , selectedItems , onSel
73
73
  legendContent = /*#__PURE__*/ _jsx(TableLegend, {
74
74
  ...commonLegendProps,
75
75
  onSelectedItemsChange: onSelectedItemsChange,
76
- width: width
76
+ width: width,
77
+ ...tableProps
77
78
  });
78
79
  } else if (options.position === 'Right' || needsVirtualization) {
79
80
  legendContent = /*#__PURE__*/ _jsx(ListLegend, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/Legend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { produce } from 'immer';\nimport { ReactNode } from 'react';\nimport { LegendOptions, LegendItem, SelectedLegendItemState, getLegendMode } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\nimport { TableLegend } from './TableLegend';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendOptions;\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// 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({ width, height, options, data, selectedItems, onSelectedItemsChange }: LegendProps) {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => {\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 };\n\n let legendContent: ReactNode;\n if (mode === 'Table') {\n legendContent = <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} />;\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 sx={{\n width: width,\n height: height,\n position: 'absolute',\n top: 0,\n right: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n bottom: 0,\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","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","sx","top","right","bottom"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,OAAO,QAAQ,OAAO,CAAC;AAEhC,SAA6DC,aAAa,QAAQ,UAAU,CAAC;AAC7F,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAChD,SAASC,WAAW,QAAQ,eAAe,CAAC;AAsB5C,4EAA4E;AAC5E,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,wDAAwD;AACxD,MAAMC,yBAAyB,GAAG,GAAG,AAAC;AAEtC,OAAO,SAASC,MAAM,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,IAAI,CAAA,EAAEC,aAAa,CAAA,EAAEC,qBAAqB,CAAA,EAAe,EAAE;IAC1G,MAAMC,iBAAiB,GAAG,CAACC,CAA4C,EAAEC,QAAgB,GAAK;QAC5F,MAAMC,eAAe,GAAGF,CAAC,CAACG,OAAO,IAAIH,CAAC,CAACI,QAAQ,AAAC;QAEhD,MAAMC,WAAW,GAAGnB,OAAO,CAACW,aAAa,EAAE,CAACS,KAAK,GAAK;YACpD,IAAIA,KAAK,KAAK,KAAK,EAAE;gBACnB,OAAO;oBACL,CA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zB,UAAU;YAAE,GAAGuB,iBAAiB;YAAElB,KAAK,EAAEA,KAAK;YAAEM,iBAAiB,EAAEA,iBAAiB;UAAI,CAAC;IAC5G,OAAO;QACLc,aAAa,iBAAG,KAACxB,aAAa;YAAE,GAAGsB,iBAAiB;YAAEZ,iBAAiB,EAAEA,iBAAiB;UAAI,CAAC;IACjG,CAAC;IAED,IAAIJ,OAAO,CAACmB,QAAQ,KAAK,OAAO,EAAE;QAChC,qBACE,KAAC7B,GAAG;YACF8B,EAAE,EAAE;gBACFtB,KAAK,EAAEA,KAAK;gBACZC,MAAM,EAAEA,MAAM;gBACdoB,QAAQ,EAAE,UAAU;gBACpBE,GAAG,EAAE,CAAC;gBACNC,KAAK,EAAE,CAAC;aACT;sBAEAJ,aAAa;UACV,CACN;IACJ,CAAC;IAED,kBAAkB;IAClB,qBACE,KAAC5B,GAAG;QACF8B,EAAE,EAAE;YACFtB,KAAK,EAAEA,KAAK;YACZC,MAAM,EAAEA,MAAM;YACdoB,QAAQ,EAAE,UAAU;YACpBI,MAAM,EAAE,CAAC;SACV;kBAEAL,aAAa;MACV,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/Legend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { produce } from 'immer';\nimport { 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';\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 * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns'>;\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 tableProps,\n}: LegendProps) {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => {\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 };\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 sx={{\n width: width,\n height: height,\n position: 'absolute',\n top: 0,\n right: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n bottom: 0,\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","tableProps","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","sx","top","right","bottom"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,OAAO,QAAQ,OAAO,CAAC;AAEhC,SAASC,aAAa,QAAQ,kBAAkB,CAAC;AACjD,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAChD,SAASC,WAAW,QAA0B,eAAe,CAAC;AA4B9D,4EAA4E;AAC5E,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,wDAAwD;AACxD,MAAMC,yBAAyB,GAA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
- import { LegendItem, SelectedLegendItemState } from '../model';
3
2
  import { ListLegendItemProps } from './ListLegendItem';
3
+ import { LegendItem, SelectedLegendItemState } from './legend-model';
4
4
  export interface ListLegendProps {
5
5
  items: LegendItem[];
6
6
  height: number;
@@ -1 +1 @@
1
- {"version":3,"file":"ListLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,eAAe,eA6BrG"}
1
+ {"version":3,"file":"ListLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAgC,MAAM,gBAAgB,CAAC;AAEnG,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,uBAAuB,CAAC;IACvC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,eAAe,eA6BrG"}
@@ -12,8 +12,8 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Virtuoso } from 'react-virtuoso';
15
- import { isLegendItemVisuallySelected } from '../model';
16
15
  import { ListLegendItem } from './ListLegendItem';
16
+ import { isLegendItemVisuallySelected } from './legend-model';
17
17
  /**
18
18
  * ListLegend is used when legend.position is 'right' since legend items are
19
19
  * stacked. It is also used for `bottom` positioned legends when there are a
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/ListLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Virtuoso } from 'react-virtuoso';\nimport { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from '../model';\nimport { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\n\nexport interface ListLegendProps {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n}\n\n/**\n * ListLegend is used when legend.position is 'right' since legend items are\n * stacked. It is also used for `bottom` positioned legends when there are a\n * large number of items because it is virtualized and easier to visually scan\n * large numbers of items when there is a single item per row.\n */\nexport function ListLegend({ items, height, width, selectedItems, onLegendItemClick }: ListLegendProps) {\n // show full labels on hover when there are many total series\n const truncateLabels = items.length > 5;\n\n return (\n <Virtuoso\n style={{ height, width }}\n data={items}\n itemContent={(index, item) => {\n return (\n <ListLegendItem\n key={item.id}\n item={item}\n truncateLabel={truncateLabels}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n sx={{\n // Having an explicit width is important for the ellipsizing to\n // work correctly. Subtract padding to simulate padding.\n width: width,\n wordBreak: 'break-word',\n overflow: 'hidden',\n }}\n />\n );\n }}\n role=\"list\"\n />\n );\n}\n"],"names":["Virtuoso","isLegendItemVisuallySelected","ListLegendItem","ListLegend","items","height","width","selectedItems","onLegendItemClick","truncateLabels","length","style","data","itemContent","index","item","truncateLabel","isVisuallySelected","onClick","sx","wordBreak","overflow","id","role"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,gBAAgB,CAAC;AAC1C,SAA8CC,4BAA4B,QAAQ,UAAU,CAAC;AAC7F,SAASC,cAAc,QAA6B,kBAAkB,CAAC;AAUvE;;;;;CAKC,GACD,OAAO,SAASC,UAAU,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAEC,aAAa,CAAA,EAAEC,iBAAiB,CAAA,EAAmB,EAAE;IACtG,6DAA6D;IAC7D,MAAMC,cAAc,GAAGL,KAAK,CAACM,MAAM,GAAG,CAAC,AAAC;IAExC,qBACE,KAACV,QAAQ;QACPW,KAAK,EAAE;YAAEN,MAAM;YAAEC,KAAK;SAAE;QACxBM,IAAI,EAAER,KAAK;QACXS,WAAW,EAAE,CAACC,KAAK,EAAEC,IAAI,GAAK;YAC5B,qBACE,KAACb,cAAc;gBAEba,IAAI,EAAEA,IAAI;gBACVC,aAAa,EAAEP,cAAc;gBAC7BQ,kBAAkB,EAAEhB,4BAA4B,CAACc,IAAI,EAAER,aAAa,CAAC;gBACrEW,OAAO,EAAEV,iBAAiB;gBAC1BW,EAAE,EAAE;oBACF,+DAA+D;oBAC/D,wDAAwD;oBACxDb,KAAK,EAAEA,KAAK;oBACZc,SAAS,EAAE,YAAY;oBACvBC,QAAQ,EAAE,QAAQ;iBACnB;eAXIN,IAAI,CAACO,EAAE,CAYZ,CACF;QACJ,CAAC;QACDC,IAAI,EAAC,MAAM;MACX,CACF;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/ListLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Virtuoso } from 'react-virtuoso';\nimport { ListLegendItem, ListLegendItemProps } from './ListLegendItem';\nimport { LegendItem, SelectedLegendItemState, isLegendItemVisuallySelected } from './legend-model';\n\nexport interface ListLegendProps {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n}\n\n/**\n * ListLegend is used when legend.position is 'right' since legend items are\n * stacked. It is also used for `bottom` positioned legends when there are a\n * large number of items because it is virtualized and easier to visually scan\n * large numbers of items when there is a single item per row.\n */\nexport function ListLegend({ items, height, width, selectedItems, onLegendItemClick }: ListLegendProps) {\n // show full labels on hover when there are many total series\n const truncateLabels = items.length > 5;\n\n return (\n <Virtuoso\n style={{ height, width }}\n data={items}\n itemContent={(index, item) => {\n return (\n <ListLegendItem\n key={item.id}\n item={item}\n truncateLabel={truncateLabels}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n sx={{\n // Having an explicit width is important for the ellipsizing to\n // work correctly. Subtract padding to simulate padding.\n width: width,\n wordBreak: 'break-word',\n overflow: 'hidden',\n }}\n />\n );\n }}\n role=\"list\"\n />\n );\n}\n"],"names":["Virtuoso","ListLegendItem","isLegendItemVisuallySelected","ListLegend","items","height","width","selectedItems","onLegendItemClick","truncateLabels","length","style","data","itemContent","index","item","truncateLabel","isVisuallySelected","onClick","sx","wordBreak","overflow","id","role"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,gBAAgB,CAAC;AAC1C,SAASC,cAAc,QAA6B,kBAAkB,CAAC;AACvE,SAA8CC,4BAA4B,QAAQ,gBAAgB,CAAC;AAUnG;;;;;CAKC,GACD,OAAO,SAASC,UAAU,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAEC,aAAa,CAAA,EAAEC,iBAAiB,CAAA,EAAmB,EAAE;IACtG,6DAA6D;IAC7D,MAAMC,cAAc,GAAGL,KAAK,CAACM,MAAM,GAAG,CAAC,AAAC;IAExC,qBACE,KAACV,QAAQ;QACPW,KAAK,EAAE;YAAEN,MAAM;YAAEC,KAAK;SAAE;QACxBM,IAAI,EAAER,KAAK;QACXS,WAAW,EAAE,CAACC,KAAK,EAAEC,IAAI,GAAK;YAC5B,qBACE,KAACd,cAAc;gBAEbc,IAAI,EAAEA,IAAI;gBACVC,aAAa,EAAEP,cAAc;gBAC7BQ,kBAAkB,EAAEf,4BAA4B,CAACa,IAAI,EAAER,aAAa,CAAC;gBACrEW,OAAO,EAAEV,iBAAiB;gBAC1BW,EAAE,EAAE;oBACF,+DAA+D;oBAC/D,wDAAwD;oBACxDb,KAAK,EAAEA,KAAK;oBACZc,SAAS,EAAE,YAAY;oBACvBC,QAAQ,EAAE,QAAQ;iBACnB;eAXIN,IAAI,CAACO,EAAE,CAYZ,CACF;QACJ,CAAC;QACDC,IAAI,EAAC,MAAM;MACX,CACF;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ListItemProps } from '@mui/material';
3
- import { LegendItem } from '../model';
3
+ import { LegendItem } from './legend-model';
4
4
  export interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick'> {
5
5
  item: LegendItem;
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ListLegendItem.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegendItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAA+B,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAChF,IAAI,EAAE,UAAU,CAAC;IAEjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAElF;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAwDD,eAAO,MAAM,cAAc,o6JAAiC,CAAC"}
1
+ {"version":3,"file":"ListLegendItem.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegendItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAA+B,aAAa,EAAE,MAAM,eAAe,CAAC;AAG3E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAChF,IAAI,EAAE,UAAU,CAAC;IAEjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAElF;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAwDD,eAAO,MAAM,cAAc,o6JAAiC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Legend/ListLegendItem.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { forwardRef, useState } from 'react';\nimport { Box, ListItemText, ListItem, ListItemProps } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { combineSx } from '../utils';\nimport { LegendColorBadge } from './LegendColorBadge';\n\nexport interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick'> {\n item: LegendItem;\n\n /**\n * When true, the item is rendered differently to visually communicate it is\n * selected.\n */\n isVisuallySelected?: boolean;\n\n onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => void;\n\n /**\n * When `true`, will keep labels to a single line with overflow ellipsized. The\n * full content will be shown on hover.\n *\n * When `false` or unset, will show the full label.\n */\n truncateLabel?: boolean;\n}\n\nconst ListLegendItemBase = forwardRef<HTMLDivElement, ListLegendItemProps>(function ListLegendItem(\n { item, sx, truncateLabel, onClick, isVisuallySelected, ...others },\n ref\n) {\n const [noWrap, setNoWrap] = useState(truncateLabel);\n\n function handleMouseOver() {\n if (truncateLabel) {\n setNoWrap(false);\n }\n }\n\n function handleMouseOut() {\n if (truncateLabel) {\n setNoWrap(true);\n }\n }\n\n const handleClick: React.MouseEventHandler<HTMLDivElement> = (e) => {\n onClick(e, item.id);\n item.onClick?.(e);\n };\n\n return (\n <ListItem\n {...others}\n component=\"div\"\n role=\"listitem\"\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx\n )}\n dense={true}\n key={item.id}\n onClick={handleClick}\n selected={isVisuallySelected}\n ref={ref}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText\n primary={item.label}\n primaryTypographyProps={{ noWrap: noWrap }}\n onMouseOver={handleMouseOver}\n onMouseOut={handleMouseOut}\n ></ListItemText>\n </ListItem>\n );\n});\n\nexport const ListLegendItem = React.memo(ListLegendItemBase);\n"],"names":["React","forwardRef","useState","Box","ListItemText","ListItem","combineSx","LegendColorBadge","ListLegendItemBase","ListLegendItem","item","sx","truncateLabel","onClick","isVisuallySelected","others","ref","noWrap","setNoWrap","handleMouseOver","handleMouseOut","handleClick","e","id","component","role","padding","cursor","dense","key","selected","display","alignItems","color","primary","label","primaryTypographyProps","onMouseOver","onMouseOut","memo"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACpD,SAASC,GAAG,EAAEC,YAAY,EAAEC,QAAQ,QAAuB,eAAe,CAAC;AAE3E,SAASC,SAAS,QAAQ,UAAU,CAAC;AACrC,SAASC,gBAAgB,QAAQ,oBAAoB,CAAC;AAsBtD,MAAMC,kBAAkB,iBAAGP,UAAU,CAAsC,SAASQ,cAAc,CAChG,EAAEC,IAAI,CAAA,EAAEC,EAAE,CAAA,EAAEC,aAAa,CAA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AY;gBACX8B,OAAO,EAAExB,IAAI,CAACyB,KAAK;gBACnBC,sBAAsB,EAAE;oBAAEnB,MAAM,EAAEA,MAAM;iBAAE;gBAC1CoB,WAAW,EAAElB,eAAe;gBAC5BmB,UAAU,EAAElB,cAAc;cACZ;;MACP,CACX;AACJ,CAAC,CAAC,AAAC;AAEH,OAAO,MAAMX,cAAc,iBAAGT,KAAK,CAACuC,IAAI,CAAC/B,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/Legend/ListLegendItem.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { forwardRef, useState } from 'react';\nimport { Box, ListItemText, ListItem, ListItemProps } from '@mui/material';\nimport { combineSx } from '../utils';\nimport { LegendColorBadge } from './LegendColorBadge';\nimport { LegendItem } from './legend-model';\n\nexport interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick'> {\n item: LegendItem;\n\n /**\n * When true, the item is rendered differently to visually communicate it is\n * selected.\n */\n isVisuallySelected?: boolean;\n\n onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string) => void;\n\n /**\n * When `true`, will keep labels to a single line with overflow ellipsized. The\n * full content will be shown on hover.\n *\n * When `false` or unset, will show the full label.\n */\n truncateLabel?: boolean;\n}\n\nconst ListLegendItemBase = forwardRef<HTMLDivElement, ListLegendItemProps>(function ListLegendItem(\n { item, sx, truncateLabel, onClick, isVisuallySelected, ...others },\n ref\n) {\n const [noWrap, setNoWrap] = useState(truncateLabel);\n\n function handleMouseOver() {\n if (truncateLabel) {\n setNoWrap(false);\n }\n }\n\n function handleMouseOut() {\n if (truncateLabel) {\n setNoWrap(true);\n }\n }\n\n const handleClick: React.MouseEventHandler<HTMLDivElement> = (e) => {\n onClick(e, item.id);\n item.onClick?.(e);\n };\n\n return (\n <ListItem\n {...others}\n component=\"div\"\n role=\"listitem\"\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx\n )}\n dense={true}\n key={item.id}\n onClick={handleClick}\n selected={isVisuallySelected}\n ref={ref}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText\n primary={item.label}\n primaryTypographyProps={{ noWrap: noWrap }}\n onMouseOver={handleMouseOver}\n onMouseOut={handleMouseOut}\n ></ListItemText>\n </ListItem>\n );\n});\n\nexport const ListLegendItem = React.memo(ListLegendItemBase);\n"],"names":["React","forwardRef","useState","Box","ListItemText","ListItem","combineSx","LegendColorBadge","ListLegendItemBase","ListLegendItem","item","sx","truncateLabel","onClick","isVisuallySelected","others","ref","noWrap","setNoWrap","handleMouseOver","handleMouseOut","handleClick","e","id","component","role","padding","cursor","dense","key","selected","display","alignItems","color","primary","label","primaryTypographyProps","onMouseOver","onMouseOut","memo"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACpD,SAASC,GAAG,EAAEC,YAAY,EAAEC,QAAQ,QAAuB,eAAe,CAAC;AAC3E,SAASC,SAAS,QAAQ,UAAU,CAAC;AACrC,SAASC,gBAAgB,QAAQ,oBAAoB,CAAC;AAuBtD,MAAMC,kBAAkB,iBAAGP,UAAU,CAAsC,SAASQ,cAAc,CAChG,EAAEC,IAAI,CAAA,EAAEC,E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AAI;cACnC;0BACN,KAAC7B,YAAY;gBACX8B,OAAO,EAAExB,IAAI,CAACyB,KAAK;gBACnBC,sBAAsB,EAAE;oBAAEnB,MAAM,EAAEA,MAAM;iBAAE;gBAC1CoB,WAAW,EAAElB,eAAe;gBAC5BmB,UAAU,EAAElB,cAAc;cACZ;;MACP,CACX;AACJ,CAAC,CAAC,AAAC;AAEH,OAAO,MAAMX,cAAc,iBAAGT,KAAK,CAACuC,IAAI,CAAC/B,kBAAkB,CAAC,CAAC"}
@@ -1,12 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { TableProps } from '../Table';
3
- import { LegendItem } from '../model';
3
+ import { LegendItem } from './legend-model';
4
4
  export interface TableLegendProps {
5
5
  items: LegendItem[];
6
6
  height: number;
7
7
  width: number;
8
8
  selectedItems: TableProps<LegendItem>['rowSelection'] | 'ALL';
9
9
  onSelectedItemsChange: TableProps<LegendItem>['onRowSelectionChange'];
10
+ columns?: TableProps<LegendItem>['columns'];
10
11
  }
11
- export declare function TableLegend({ items, selectedItems: initRowSelection, onSelectedItemsChange, height, width, }: TableLegendProps): JSX.Element;
12
+ export declare function TableLegend({ items, selectedItems: initRowSelection, onSelectedItemsChange, height, width, columns: additionalColumns, }: TableLegendProps): JSX.Element;
12
13
  //# sourceMappingURL=TableLegend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/TableLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAS,UAAU,EAAqB,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;IAC9D,qBAAqB,EAAE,UA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