@perses-dev/components 0.35.0 → 0.36.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 (177) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.d.ts +1 -1
  2. package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -1
  3. package/dist/ContentWithLegend/ContentWithLegend.js +4 -2
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +9 -3
  6. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  7. package/dist/ContentWithLegend/model/content-with-legend-model.js +17 -7
  8. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  9. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -1
  10. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
  11. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  12. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts +2 -5
  13. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
  14. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  15. package/dist/GaugeChart/GaugeChart.d.ts +1 -1
  16. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  17. package/dist/GaugeChart/GaugeChart.js +1 -2
  18. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  19. package/dist/Legend/CompactLegend.d.ts +3 -1
  20. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  21. package/dist/Legend/CompactLegend.js +5 -2
  22. package/dist/Legend/CompactLegend.js.map +1 -1
  23. package/dist/Legend/Legend.d.ts +11 -2
  24. package/dist/Legend/Legend.d.ts.map +1 -1
  25. package/dist/Legend/Legend.js +4 -2
  26. package/dist/Legend/Legend.js.map +1 -1
  27. package/dist/Legend/ListLegend.d.ts +3 -1
  28. package/dist/Legend/ListLegend.d.ts.map +1 -1
  29. package/dist/Legend/ListLegend.js +5 -4
  30. package/dist/Legend/ListLegend.js.map +1 -1
  31. package/dist/Legend/ListLegendItem.d.ts +15 -2
  32. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  33. package/dist/Legend/ListLegendItem.js +17 -5
  34. package/dist/Legend/ListLegendItem.js.map +1 -1
  35. package/dist/Legend/TableLegend.d.ts +4 -2
  36. package/dist/Legend/TableLegend.d.ts.map +1 -1
  37. package/dist/Legend/TableLegend.js +8 -2
  38. package/dist/Legend/TableLegend.js.map +1 -1
  39. package/dist/LineChart/LineChart.d.ts +17 -3
  40. package/dist/LineChart/LineChart.d.ts.map +1 -1
  41. package/dist/LineChart/LineChart.js +33 -7
  42. package/dist/LineChart/LineChart.js.map +1 -1
  43. package/dist/LineChart/utils.d.ts +2 -1
  44. package/dist/LineChart/utils.d.ts.map +1 -1
  45. package/dist/LineChart/utils.js +14 -1
  46. package/dist/LineChart/utils.js.map +1 -1
  47. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +12 -0
  48. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts.map +1 -0
  49. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +45 -0
  50. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -0
  51. package/dist/RefreshIntervalPicker/index.d.ts +2 -0
  52. package/dist/RefreshIntervalPicker/index.d.ts.map +1 -0
  53. package/dist/{model/units → RefreshIntervalPicker}/index.js +1 -3
  54. package/dist/RefreshIntervalPicker/index.js.map +1 -0
  55. package/dist/StatChart/StatChart.d.ts +1 -1
  56. package/dist/StatChart/StatChart.d.ts.map +1 -1
  57. package/dist/StatChart/StatChart.js +1 -1
  58. package/dist/StatChart/StatChart.js.map +1 -1
  59. package/dist/Table/InnerTable.js +2 -2
  60. package/dist/Table/InnerTable.js.map +1 -1
  61. package/dist/Table/Table.d.ts +1 -1
  62. package/dist/Table/Table.d.ts.map +1 -1
  63. package/dist/Table/Table.js +57 -9
  64. package/dist/Table/Table.js.map +1 -1
  65. package/dist/Table/TableCell.d.ts +11 -1
  66. package/dist/Table/TableCell.d.ts.map +1 -1
  67. package/dist/Table/TableCell.js +8 -3
  68. package/dist/Table/TableCell.js.map +1 -1
  69. package/dist/Table/TableCheckbox.js +1 -1
  70. package/dist/Table/TableCheckbox.js.map +1 -1
  71. package/dist/Table/TableHeaderCell.d.ts +23 -0
  72. package/dist/Table/TableHeaderCell.d.ts.map +1 -0
  73. package/dist/Table/TableHeaderCell.js +53 -0
  74. package/dist/Table/TableHeaderCell.js.map +1 -0
  75. package/dist/Table/VirtualizedTable.d.ts +3 -3
  76. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  77. package/dist/Table/VirtualizedTable.js +43 -8
  78. package/dist/Table/VirtualizedTable.js.map +1 -1
  79. package/dist/Table/model/table-model.d.ts +71 -7
  80. package/dist/Table/model/table-model.d.ts.map +1 -1
  81. package/dist/Table/model/table-model.js +6 -2
  82. package/dist/Table/model/table-model.js.map +1 -1
  83. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +2 -1
  84. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
  85. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -1
  86. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
  87. package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -1
  88. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  89. package/dist/TimeSeriesTooltip/nearby-series.js +2 -11
  90. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  91. package/dist/UnitSelector/UnitSelector.d.ts +1 -1
  92. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
  93. package/dist/UnitSelector/UnitSelector.js +1 -2
  94. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  95. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +4 -2
  96. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +17 -7
  97. package/dist/cjs/GaugeChart/GaugeChart.js +2 -3
  98. package/dist/cjs/Legend/CompactLegend.js +5 -2
  99. package/dist/cjs/Legend/Legend.js +4 -2
  100. package/dist/cjs/Legend/ListLegend.js +5 -4
  101. package/dist/cjs/Legend/ListLegendItem.js +17 -5
  102. package/dist/cjs/Legend/TableLegend.js +8 -2
  103. package/dist/cjs/LineChart/LineChart.js +31 -5
  104. package/dist/cjs/LineChart/utils.js +14 -3
  105. package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +51 -0
  106. package/dist/cjs/{model/units → RefreshIntervalPicker}/index.js +1 -3
  107. package/dist/cjs/StatChart/StatChart.js +4 -4
  108. package/dist/cjs/Table/InnerTable.js +2 -2
  109. package/dist/cjs/Table/Table.js +56 -8
  110. package/dist/cjs/Table/TableCell.js +8 -3
  111. package/dist/cjs/Table/TableCheckbox.js +1 -1
  112. package/dist/cjs/Table/TableHeaderCell.js +59 -0
  113. package/dist/cjs/Table/VirtualizedTable.js +43 -8
  114. package/dist/cjs/Table/model/table-model.js +6 -2
  115. package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -1
  116. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -11
  117. package/dist/cjs/UnitSelector/UnitSelector.js +6 -7
  118. package/dist/cjs/index.js +1 -0
  119. package/dist/cjs/model/index.js +1 -1
  120. package/dist/{model/units/types.js → cjs/model/timeOption.js} +4 -10
  121. package/dist/index.d.ts +1 -0
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +1 -0
  124. package/dist/index.js.map +1 -1
  125. package/dist/model/index.d.ts +1 -1
  126. package/dist/model/index.d.ts.map +1 -1
  127. package/dist/model/index.js +1 -1
  128. package/dist/model/index.js.map +1 -1
  129. package/dist/model/theme.d.ts +1 -4
  130. package/dist/model/theme.d.ts.map +1 -1
  131. package/dist/model/theme.js.map +1 -1
  132. package/dist/model/timeOption.d.ts +6 -0
  133. package/dist/model/timeOption.d.ts.map +1 -0
  134. package/dist/model/{units/constants.js → timeOption.js} +2 -4
  135. package/dist/model/timeOption.js.map +1 -0
  136. package/package.json +3 -4
  137. package/dist/cjs/model/units/bytes.js +0 -84
  138. package/dist/cjs/model/units/constants.js +0 -23
  139. package/dist/cjs/model/units/decimal.js +0 -62
  140. package/dist/cjs/model/units/percent.js +0 -73
  141. package/dist/cjs/model/units/time.js +0 -105
  142. package/dist/cjs/model/units/types.js +0 -28
  143. package/dist/cjs/model/units/units.js +0 -101
  144. package/dist/cjs/model/units/utils.js +0 -42
  145. package/dist/model/units/bytes.d.ts +0 -13
  146. package/dist/model/units/bytes.d.ts.map +0 -1
  147. package/dist/model/units/bytes.js +0 -66
  148. package/dist/model/units/bytes.js.map +0 -1
  149. package/dist/model/units/constants.d.ts +0 -2
  150. package/dist/model/units/constants.d.ts.map +0 -1
  151. package/dist/model/units/constants.js.map +0 -1
  152. package/dist/model/units/decimal.d.ts +0 -13
  153. package/dist/model/units/decimal.d.ts.map +0 -1
  154. package/dist/model/units/decimal.js +0 -49
  155. package/dist/model/units/decimal.js.map +0 -1
  156. package/dist/model/units/index.d.ts +0 -4
  157. package/dist/model/units/index.d.ts.map +0 -1
  158. package/dist/model/units/index.js.map +0 -1
  159. package/dist/model/units/percent.d.ts +0 -12
  160. package/dist/model/units/percent.d.ts.map +0 -1
  161. package/dist/model/units/percent.js +0 -60
  162. package/dist/model/units/percent.js.map +0 -1
  163. package/dist/model/units/time.d.ts +0 -22
  164. package/dist/model/units/time.d.ts.map +0 -1
  165. package/dist/model/units/time.js +0 -91
  166. package/dist/model/units/time.js.map +0 -1
  167. package/dist/model/units/types.d.ts +0 -47
  168. package/dist/model/units/types.d.ts.map +0 -1
  169. package/dist/model/units/types.js.map +0 -1
  170. package/dist/model/units/units.d.ts +0 -40
  171. package/dist/model/units/units.d.ts.map +0 -1
  172. package/dist/model/units/units.js +0 -80
  173. package/dist/model/units/units.js.map +0 -1
  174. package/dist/model/units/utils.d.ts +0 -4
  175. package/dist/model/units/utils.d.ts.map +0 -1
  176. package/dist/model/units/utils.js +0 -32
  177. package/dist/model/units/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Table/TableCheckbox.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 { Checkbox, CheckboxProps, alpha } from '@mui/material';\nimport { TableDensity } from './model/table-model';\n\nexport interface TableCheckboxProps extends Pick<CheckboxProps, 'checked' | 'indeterminate' | 'onChange'> {\n color?: string;\n density: TableDensity;\n}\n\nexport function TableCheckbox({ color, density, ...otherProps }: TableCheckboxProps) {\n const isCompact = density === 'compact';\n\n return (\n <Checkbox\n size={isCompact ? 'small' : 'medium'}\n {...otherProps}\n // Disable ripple and set background color below because of some issues\n // with re-rendering with the keyboard interactions that causes the ripple\n // animation to stutter.\n focusRipple={false}\n // Tab index is handled by the overall keyboard interactions for the table\n // to avoid trapping a keyboard user in a table by requiring them to tab\n // through every single checkbox.\n tabIndex={-1}\n sx={{\n color: color,\n\n padding: (theme) => theme.spacing(isCompact ? 0.25 : 0.5),\n\n // Centering.\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n\n '&.Mui-checked': {\n color: color,\n },\n\n '&.Mui-focusVisible': {\n background: color ? alpha(color, 0.5) : undefined,\n },\n\n '& .MuiSvgIcon-root': { fontSize: isCompact ? 14 : 16 },\n }}\n />\n );\n}\n"],"names":["Checkbox","alpha","TableCheckbox","color","density","otherProps","isCompact","size","focusRipple","tabIndex","sx","padding","theme","spacing","position","top","left","transform","background","undefined","font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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 { Checkbox, CheckboxProps, alpha } from '@mui/material';\nimport { TableDensity } from './model/table-model';\n\nexport interface TableCheckboxProps extends Pick<CheckboxProps, 'checked' | 'indeterminate' | 'onChange'> {\n color?: string;\n density: TableDensity;\n}\n\nexport function TableCheckbox({ color, density, ...otherProps }: TableCheckboxProps) {\n const isCompact = density === 'compact';\n\n return (\n <Checkbox\n size={isCompact ? 'small' : 'medium'}\n {...otherProps}\n // Disable ripple and set background color below because of some issues\n // with re-rendering with the keyboard interactions that causes the ripple\n // animation to stutter.\n focusRipple={false}\n // Tab index is handled by the overall keyboard interactions for the table\n // to avoid trapping a keyboard user in a table by requiring them to tab\n // through every single checkbox.\n tabIndex={-1}\n sx={{\n color: color,\n\n padding: (theme) => theme.spacing(isCompact ? 0.25 : 0.5),\n\n // Centering.\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n\n '&.Mui-checked': {\n color: color,\n },\n\n '&.Mui-focusVisible': {\n background: color ? alpha(color, 0.5) : undefined,\n },\n\n '& .MuiSvgIcon-root': { fontSize: isCompact ? 16 : 18 },\n }}\n />\n );\n}\n"],"names":["Checkbox","alpha","TableCheckbox","color","density","otherProps","isCompact","size","focusRipple","tabIndex","sx","padding","theme","spacing","position","top","left","transform","background","undefined","fontSize"],"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,EAAiBC,KAAK,QAAQ,eAAe,CAAC;AAQ/D,OAAO,SAASC,aAAa,CAAC,EAAEC,KAAK,CAAA,EAAEC,OAAO,CAAA,EAAE,GAAGC,UAAU,EAAsB,EAAE;IACnF,MAAMC,SAAS,GAAGF,OAAO,KAAK,SAAS,AAAC;IAExC,qBACE,KAACJ,QAAQ;QACPO,IAAI,EAAED,SAAS,GAAG,OAAO,GAAG,QAAQ;QACnC,GAAGD,UAAU;QACd,uEAAuE;QACvE,0EAA0E;QAC1E,wBAAwB;QACxBG,WAAW,EAAE,KAAK;QAClB,0EAA0E;QAC1E,wEAAwE;QACxE,iCAAiC;QACjCC,QAAQ,EAAE,CAAC,CAAC;QACZC,EAAE,EAAE;YACFP,KAAK,EAAEA,KAAK;YAEZQ,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACP,SAAS,GAAG,IAAI,GAAG,GAAG,CAAC;YAEzD,aAAa;YACbQ,QAAQ,EAAE,UAAU;YACpBC,GAAG,EAAE,KAAK;YACVC,IAAI,EAAE,KAAK;YACXC,SAAS,EAAE,uBAAuB;YAElC,eAAe,EAAE;gBACfd,KAAK,EAAEA,KAAK;aACb;YAED,oBAAoB,EAAE;gBACpBe,UAAU,EAAEf,KAAK,GAAGF,KAAK,CAACE,KAAK,EAAE,GAAG,CAAC,GAAGgB,SAAS;aAClD;YAED,oBAAoB,EAAE;gBAAEC,QAAQ,EAAEd,SAAS,GAAG,EAAE,GAAG,EAAE;aAAE;SACxD;MACD,CACF;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { SortDirection } from './model/table-model';
3
+ import { TableCellProps } from './TableCell';
4
+ export interface TableHeaderCellProps extends TableCellProps {
5
+ /**
6
+ * Handler called when a sort event is triggered.
7
+ * When specified, the header will include sorting interactions and indicators.
8
+ */
9
+ onSort?: ((event: unknown) => void) | undefined;
10
+ /**
11
+ * The current direction the header is sorted.
12
+ */
13
+ sortDirection?: SortDirection;
14
+ /**
15
+ * The next direction the header will be sorted when another sort action
16
+ * is triggered via click/keyboard. This impacts some UI interactions (e.g.
17
+ * the direction of the sort arrow on hover f the column is currently
18
+ * unsorted.)
19
+ */
20
+ nextSortDirection?: SortDirection;
21
+ }
22
+ export declare function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, ...cellProps }: TableHeaderCellProps): JSX.Element;
23
+ //# sourceMappingURL=TableHeaderCell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableHeaderCell.d.ts","sourceRoot":"","sources":["../../src/Table/TableHeaderCell.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAa,cAAc,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAEhD;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,aAAa,CAAC;CACnC;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,oBAAoB,eA4CtB"}
@@ -0,0 +1,53 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { TableSortLabel, Typography, tableSortLabelClasses } from '@mui/material';
15
+ import { TableCell } from './TableCell';
16
+ export function TableHeaderCell({ onSort , sortDirection , nextSortDirection , children , ...cellProps }) {
17
+ const showSortLabel = !!onSort;
18
+ const headerText = /*#__PURE__*/ _jsx(Typography, {
19
+ noWrap: true,
20
+ variant: "inherit",
21
+ component: "div",
22
+ color: "inherit",
23
+ children: children
24
+ });
25
+ const isActive = !!sortDirection;
26
+ const direction = isActive ? sortDirection : nextSortDirection;
27
+ return /*#__PURE__*/ _jsx(TableCell, {
28
+ ...cellProps,
29
+ children: showSortLabel ? /*#__PURE__*/ _jsx(TableSortLabel, {
30
+ onClick: onSort,
31
+ direction: direction,
32
+ active: isActive,
33
+ sx: {
34
+ // Overrides a default vertical alignment in the CSS that changes
35
+ // the header vertical rhythm in a way that's inconsistent with
36
+ // non-sorting headers.
37
+ verticalAlign: 'unset',
38
+ // Makes it possible to ellipsize the text if it's too long.
39
+ maxWidth: '100%',
40
+ // Make the arrow visible when focused using the keyboard to assist
41
+ // with a11y.
42
+ '&:focus-visible': {
43
+ [`& .${tableSortLabelClasses.icon}`]: {
44
+ opacity: isActive ? 1 : 0.5
45
+ }
46
+ }
47
+ },
48
+ children: headerText
49
+ }) : headerText
50
+ });
51
+ }
52
+
53
+ //# sourceMappingURL=TableHeaderCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Table/TableHeaderCell.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 { TableSortLabel, Typography, tableSortLabelClasses } from '@mui/material';\nimport { SortDirection } from './model/table-model';\nimport { TableCell, TableCellProps } from './TableCell';\n\nexport interface TableHeaderCellProps extends TableCellProps {\n /**\n * Handler called when a sort event is triggered.\n * When specified, the header will include sorting interactions and indicators.\n */\n onSort?: ((event: unknown) => void) | undefined;\n\n /**\n * The current direction the header is sorted.\n */\n sortDirection?: SortDirection;\n\n /**\n * The next direction the header will be sorted when another sort action\n * is triggered via click/keyboard. This impacts some UI interactions (e.g.\n * the direction of the sort arrow on hover f the column is currently\n * unsorted.)\n */\n nextSortDirection?: SortDirection;\n}\n\nexport function TableHeaderCell({\n onSort,\n sortDirection,\n nextSortDirection,\n children,\n ...cellProps\n}: TableHeaderCellProps) {\n const showSortLabel = !!onSort;\n\n const headerText = (\n <Typography noWrap variant=\"inherit\" component=\"div\" color=\"inherit\">\n {children}\n </Typography>\n );\n\n const isActive = !!sortDirection;\n const direction = isActive ? sortDirection : nextSortDirection;\n\n return (\n <TableCell {...cellProps}>\n {showSortLabel ? (\n <TableSortLabel\n onClick={onSort}\n direction={direction}\n active={isActive}\n sx={{\n // Overrides a default vertical alignment in the CSS that changes\n // the header vertical rhythm in a way that's inconsistent with\n // non-sorting headers.\n verticalAlign: 'unset',\n\n // Makes it possible to ellipsize the text if it's too long.\n maxWidth: '100%',\n\n // Make the arrow visible when focused using the keyboard to assist\n // with a11y.\n '&:focus-visible': {\n [`& .${tableSortLabelClasses.icon}`]: {\n opacity: isActive ? 1 : 0.5,\n },\n },\n }}\n >\n {headerText}\n </TableSortLabel>\n ) : (\n headerText\n )}\n </TableCell>\n );\n}\n"],"names":["TableSortLabel","Typography","tableSortLabelClasses","TableCell","TableHeaderCell","onSort","sortDirection","nextSortDirection","children","cellProps","showSortLabel","headerText","noWrap","variant","component","color","isActive","direction","onClick","active","sx","verticalAlign","maxWidth","icon","opacity"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AA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,11 @@
1
1
  /// <reference types="react" />
2
2
  import { Column, HeaderGroup, Row } from '@tanstack/react-table';
3
3
  import { TableProps } from './model/table-model';
4
- export declare type VirtualizedTableProps<TableData> = Required<Pick<TableProps<TableData>, 'height' | 'width' | 'density'>> & {
5
- onRowClick: (id: string) => void;
4
+ export declare type VirtualizedTableProps<TableData> = Required<Pick<TableProps<TableData>, 'height' | 'width' | 'density'>> & Pick<TableProps<TableData>, 'onRowMouseOver' | 'onRowMouseOut'> & {
5
+ onRowClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, id: string) => void;
6
6
  rows: Array<Row<TableData>>;
7
7
  columns: Array<Column<TableData, unknown>>;
8
8
  headers: Array<HeaderGroup<TableData>>;
9
9
  };
10
- export declare function VirtualizedTable<TableData>({ width, height, density, onRowClick, rows, columns, headers, }: VirtualizedTableProps<TableData>): JSX.Element;
10
+ export declare function VirtualizedTable<TableData>({ width, height, density, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, }: VirtualizedTableProps<TableData>): JSX.Element;
11
11
  //# sourceMappingURL=VirtualizedTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualizedTable.d.ts","sourceRoot":"","sources":["../../src/Table/VirtualizedTable.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAc,MAAM,uBAAuB,CAAC;AAU7E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQjD,oBAAY,qBAAqB,CAAC,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC,GAAG;IACrH,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,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,SAAS,CAAC,eA4KlC"}
@@ -19,13 +19,14 @@ import { TableRow } from './TableRow';
19
19
  import { TableBody } from './TableBody';
20
20
  import { InnerTable } from './InnerTable';
21
21
  import { TableHead } from './TableHead';
22
+ import { TableHeaderCell } from './TableHeaderCell';
22
23
  import { TableCell } from './TableCell';
23
24
  import { VirtualizedTableContainer } from './VirtualizedTableContainer';
24
25
  import { useVirtualizedTableKeyboardNav } from './hooks/useVirtualizedTableKeyboardNav';
25
26
  // Separating out the virtualized table because we may want a paginated table
26
27
  // in the future that does not need virtualization, and we'd likely lay them
27
28
  // out differently.
28
- export function VirtualizedTable({ width , height , density , onRowClick , rows , columns , headers }) {
29
+ export function VirtualizedTable({ width , height , density , onRowClick , onRowMouseOver , onRowMouseOut , rows , columns , headers }) {
29
30
  const virtuosoRef = useRef(null);
30
31
  // Use a ref for these values because they are only needed for keyboard
31
32
  // focus interactions and setting them on state will lead to a significant
@@ -69,10 +70,20 @@ export function VirtualizedTable({ width , height , density , onRowClick , rows
69
70
  if (!row) {
70
71
  return null;
71
72
  }
73
+ const rowEventOpts = {
74
+ id: row.id,
75
+ index: row.index
76
+ };
72
77
  return /*#__PURE__*/ _jsx(TableRow, {
73
78
  ...props,
74
- onClick: ()=>onRowClick(row.id),
75
- density: density
79
+ onClick: (e)=>onRowClick(e, row.id),
80
+ density: density,
81
+ onMouseOver: (e)=>{
82
+ onRowMouseOver === null || onRowMouseOver === void 0 ? void 0 : onRowMouseOver(e, rowEventOpts);
83
+ },
84
+ onMouseOut: (e)=>{
85
+ onRowMouseOut === null || onRowMouseOut === void 0 ? void 0 : onRowMouseOut(e, rowEventOpts);
86
+ }
76
87
  });
77
88
  },
78
89
  TableBody
@@ -81,6 +92,8 @@ export function VirtualizedTable({ width , height , density , onRowClick , rows
81
92
  density,
82
93
  keyboardNav.onTableKeyDown,
83
94
  onRowClick,
95
+ onRowMouseOut,
96
+ onRowMouseOver,
84
97
  rows,
85
98
  width
86
99
  ]);
@@ -103,17 +116,23 @@ export function VirtualizedTable({ width , height , density , onRowClick , rows
103
116
  return /*#__PURE__*/ _jsx(TableRow, {
104
117
  density: density,
105
118
  children: headerGroup.headers.map((header, i, headers)=>{
106
- var ref;
119
+ var ref, ref1;
107
120
  const column = header.column;
108
121
  const position = {
109
122
  row: 0,
110
123
  column: i
111
124
  };
112
- return /*#__PURE__*/ _jsx(TableCell, {
125
+ const isSorted = column.getIsSorted();
126
+ const nextSorting = column.getNextSortingOrder();
127
+ return /*#__PURE__*/ _jsx(TableHeaderCell, {
128
+ onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
129
+ sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
130
+ nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
113
131
  width: column.getSize() || 'auto',
114
132
  align: (ref = column.columnDef.meta) === null || ref === void 0 ? void 0 : ref.align,
115
133
  variant: "head",
116
134
  density: density,
135
+ description: (ref1 = column.columnDef.meta) === null || ref1 === void 0 ? void 0 : ref1.headerDescription,
117
136
  focusState: getFocusState(position),
118
137
  onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
119
138
  isFirstColumn: i === 0,
@@ -132,21 +151,37 @@ export function VirtualizedTable({ width , height , density , onRowClick , rows
132
151
  }
133
152
  return /*#__PURE__*/ _jsx(_Fragment, {
134
153
  children: row.getVisibleCells().map((cell, i, cells)=>{
135
- var ref;
154
+ var ref, ref1;
136
155
  const position = {
137
156
  // Add 1 to the row index because the header is row 0
138
157
  row: index + 1,
139
158
  column: i
140
159
  };
160
+ const cellContext = cell.getContext();
161
+ const cellRenderFn = cell.column.columnDef.cell;
162
+ const cellContent = typeof cellRenderFn == 'function' ? cellRenderFn(cellContext) : null;
163
+ const cellDescriptionDef = (ref = cell.column.columnDef.meta) === null || ref === void 0 ? void 0 : ref.cellDescription;
164
+ let description = undefined;
165
+ if (typeof cellDescriptionDef === 'function') {
166
+ // If the cell description is a function, set the value using
167
+ // the function.
168
+ description = cellDescriptionDef(cellContext);
169
+ } else if (cellDescriptionDef && typeof cellContent === 'string') {
170
+ // If the cell description is `true` AND the cell content is
171
+ // a string (and thus viable as a `title` attribute), use the
172
+ // cell content.
173
+ description = cellContent;
174
+ }
141
175
  return /*#__PURE__*/ _jsx(TableCell, {
142
176
  width: cell.column.getSize() || 'auto',
143
- align: (ref = cell.column.columnDef.meta) === null || ref === void 0 ? void 0 : ref.align,
177
+ align: (ref1 = cell.column.columnDef.meta) === null || ref1 === void 0 ? void 0 : ref1.align,
144
178
  density: density,
145
179
  focusState: getFocusState(position),
146
180
  onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
147
181
  isFirstColumn: i === 0,
148
182
  isLastColumn: i === cells.length - 1,
149
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
183
+ description: description,
184
+ children: cellContent
150
185
  }, cell.id);
151
186
  })
152
187
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Table/VirtualizedTable.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 { Column, HeaderGroup, Row, flexRender } from '@tanstack/react-table';\nimport { Box } from '@mui/material';\nimport { TableVirtuoso, TableComponents, TableVirtuosoHandle, TableVirtuosoProps } from 'react-virtuoso';\nimport { useRef, useMemo } from 'react';\nimport { TableRow } from './TableRow';\nimport { TableBody } from './TableBody';\nimport { InnerTable } from './InnerTable';\nimport { TableHead } from './TableHead';\nimport { TableCell, TableCellProps } from './TableCell';\nimport { VirtualizedTableContainer } from './VirtualizedTableContainer';\nimport { TableProps } from './model/table-model';\nimport { useVirtualizedTableKeyboardNav } from './hooks/useVirtualizedTableKeyboardNav';\n\ntype TableCellPosition = {\n row: number;\n column: number;\n};\n\nexport type VirtualizedTableProps<TableData> = Required<Pick<TableProps<TableData>, 'height' | 'width' | 'density'>> & {\n onRowClick: (id: string) => void;\n rows: Array<Row<TableData>>;\n columns: Array<Column<TableData, unknown>>;\n headers: Array<HeaderGroup<TableData>>;\n};\n\n// Separating out the virtualized table because we may want a paginated table\n// in the future that does not need virtualization, and we'd likely lay them\n// out differently.\nexport function VirtualizedTable<TableData>({\n width,\n height,\n density,\n onRowClick,\n rows,\n columns,\n headers,\n}: VirtualizedTableProps<TableData>) {\n const virtuosoRef = useRef<TableVirtuosoHandle>(null);\n\n // Use a ref for these values because they are only needed for keyboard\n // focus interactions and setting them on state will lead to a significant\n // amount of unnecessary re-renders.\n const visibleRange = useRef({\n startIndex: 0,\n endIndex: 0,\n });\n const setVisibleRange: TableVirtuosoProps<TableData, unknown>['rangeChanged'] = (newVisibleRange) => {\n visibleRange.current = newVisibleRange;\n };\n\n const keyboardNav = useVirtualizedTableKeyboardNav({\n visibleRange: visibleRange,\n virtualTable: virtuosoRef,\n\n // We add 1 here for the header.\n maxRows: rows.length + 1,\n maxColumns: columns.length,\n });\n\n const getFocusState = (cellPosition: TableCellPosition): TableCellProps['focusState'] => {\n if (cellPosition.row === keyboardNav.activeCell.row && cellPosition.column === keyboardNav.activeCell.column) {\n return keyboardNav.isActive ? 'trigger-focus' : 'focus-next';\n }\n\n return 'none';\n };\n\n const VirtuosoTableComponents: TableComponents<TableData> = useMemo(() => {\n return {\n Scroller: VirtualizedTableContainer,\n Table: (props) => {\n return <InnerTable {...props} width={width} density={density} onKeyDown={keyboardNav.onTableKeyDown} />;\n },\n TableHead,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TableRow: ({ item, ...props }) => {\n const index = props['data-index'];\n const row = rows[index];\n if (!row) {\n return null;\n }\n\n return <TableRow {...props} onClick={() => onRowClick(row.id)} density={density} />;\n },\n TableBody,\n };\n }, [density, keyboardNav.onTableKeyDown, onRowClick, rows, width]);\n\n return (\n <Box sx={{ width, height }}>\n <TableVirtuoso\n ref={virtuosoRef}\n totalCount={rows.length}\n components={VirtuosoTableComponents}\n // Note: this value is impacted by overscan. See this issue if overscan\n // is added.\n // https://github.com/petyosi/react-virtuoso/issues/118#issuecomment-642156138\n rangeChanged={setVisibleRange}\n fixedHeaderContent={() => {\n return (\n <>\n {headers.map((headerGroup) => {\n return (\n <TableRow key={headerGroup.id} density={density}>\n {headerGroup.headers.map((header, i, headers) => {\n const column = header.column;\n const position: TableCellPosition = {\n row: 0,\n column: i,\n };\n\n return (\n <TableCell\n key={header.id}\n width={column.getSize() || 'auto'}\n align={column.columnDef.meta?.align}\n variant=\"head\"\n density={density}\n focusState={getFocusState(position)}\n onFocusTrigger={() => keyboardNav.onCellFocus(position)}\n isFirstColumn={i === 0}\n isLastColumn={i === headers.length - 1}\n >\n {flexRender(column.columnDef.header, header.getContext())}\n </TableCell>\n );\n })}\n </TableRow>\n );\n })}\n </>\n );\n }}\n itemContent={(index) => {\n const row = rows[index];\n if (!row) {\n return null;\n }\n\n return (\n <>\n {row.getVisibleCells().map((cell, i, cells) => {\n const position: TableCellPosition = {\n // Add 1 to the row index because the header is row 0\n row: index + 1,\n column: i,\n };\n\n return (\n <TableCell\n key={cell.id}\n width={cell.column.getSize() || 'auto'}\n align={cell.column.columnDef.meta?.align}\n density={density}\n focusState={getFocusState(position)}\n onFocusTrigger={() => keyboardNav.onCellFocus(position)}\n isFirstColumn={i === 0}\n isLastColumn={i === cells.length - 1}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </TableCell>\n );\n })}\n </>\n );\n }}\n />\n </Box>\n );\n}\n"],"names":["flexRender","Box","TableVirtuoso","useRef","useMemo","TableRow","TableBody","InnerTable","TableHead","TableCell","VirtualizedTableContainer","useVirtualizedTableKeyboardNav","VirtualizedTable","width","height","density","onRowClick","rows","columns","headers","virtuosoRef","visibleRange","startIndex","endIndex","setVisibleRange","newVisibleRange","current","keyboardNav","virtualTable","maxRows","length","maxColumns","getFocusState","cellPosition","row","activeCell","column","isActive","VirtuosoTableComponents","Scroller","Table","props","onKeyDown","onTableKeyDown","item","index","onClick","id","sx","ref","totalCount","components","rangeChanged","fixedHeaderContent","map","headerGroup","header","i","position","getSize","align","columnDef","meta","variant","focusState","onFocusTrigger","onCellFocus","isFirstColumn","isLastColumn","getContext","itemContent","getVisibleCells","cell","cells"],"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,SAAmCA,UAAU,QAAQ,uBAAuB,CAAC;AAC7E,SAASC,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,aAAa,QAAkE,gBAAgB,CAAC;AACzG,SAASC,MAAM,EAAEC,OAAO,QAAQ,OAAO,CAAC;AACxC,SAASC,QAAQ,QAAQ,YAAY,CAAC;AACtC,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,SAAS,QAAwB,aAAa,CAAC;AACxD,SAASC,yBAAyB,QAAQ,6BAA6B,CAAC;AAExE,SAASC,8BAA8B,QAAQ,wCAAwC,CAAC;AAcxF,6EAA6E;AAC7E,4EAA4E;AAC5E,mBAAmB;AACnB,OAAO,SAASC,gBAAgB,CAAY,EAC1CC,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,OAAO,CAAA,EACPC,UAAU,CAAA,EACVC,IAAI,CAAA,EACJC,OAAO,CAAA,EACPC,OAAO,CAAA,EAC0B,EAAE;IACnC,MAAMC,WAAW,GAAGjB,MAAM,CAAsB,IAAI,CAAC,AAAC;IAEtD,uEAAuE;IACvE,0EAA0E;IAC1E,oCAAoC;IACpC,MAAMkB,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U,GAA0B,WAAO,GAAjCA,KAAAA,CAAiC,GAAjCA,GAA0B,CAAEZ,KAAK;4BACxC7C,OAAO,EAAEA,OAAO;4BAChBiD,UAAU,EAAEhC,aAAa,CAAC0B,QAAQ,CAAC;4BACnCO,cAAc,EAAE,IAAMtC,WAAW,CAACuC,WAAW,CAACR,QAAQ,CAAC;4BACvDS,aAAa,EAAEV,CAAC,KAAK,CAAC;4BACtBW,YAAY,EAAEX,CAAC,KAAKgB,KAAK,CAAC3C,MAAM,GAAG,CAAC;sCAEnC9B,UAAU,CAACwE,IAAI,CAACpC,MAAM,CAACyB,SAAS,CAACW,IAAI,EAAEA,IAAI,CAACH,UAAU,EAAE,CAAC;2BATrDG,IAAI,CAACzB,EAAE,CAUF,CACZ;oBACJ,CAAC,CAAC;kBACD,CACH;YACJ,CAAC;UACD;MACE,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Table/VirtualizedTable.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 { Column, HeaderGroup, Row, flexRender } from '@tanstack/react-table';\nimport { Box } from '@mui/material';\nimport { TableVirtuoso, TableComponents, TableVirtuosoHandle, TableVirtuosoProps } from 'react-virtuoso';\nimport { useRef, useMemo } from 'react';\nimport { TableRow } from './TableRow';\nimport { TableBody } from './TableBody';\nimport { InnerTable } from './InnerTable';\nimport { TableHead } from './TableHead';\nimport { TableHeaderCell } from './TableHeaderCell';\nimport { TableCell, TableCellProps } from './TableCell';\nimport { VirtualizedTableContainer } from './VirtualizedTableContainer';\nimport { TableProps, TableRowEventOpts } from './model/table-model';\nimport { useVirtualizedTableKeyboardNav } from './hooks/useVirtualizedTableKeyboardNav';\n\ntype TableCellPosition = {\n row: number;\n column: number;\n};\n\nexport type VirtualizedTableProps<TableData> = Required<Pick<TableProps<TableData>, 'height' | 'width' | 'density'>> &\n Pick<TableProps<TableData>, 'onRowMouseOver' | 'onRowMouseOut'> & {\n onRowClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, id: string) => void;\n rows: Array<Row<TableData>>;\n columns: Array<Column<TableData, unknown>>;\n headers: Array<HeaderGroup<TableData>>;\n };\n\n// Separating out the virtualized table because we may want a paginated table\n// in the future that does not need virtualization, and we'd likely lay them\n// out differently.\nexport function VirtualizedTable<TableData>({\n width,\n height,\n density,\n onRowClick,\n onRowMouseOver,\n onRowMouseOut,\n rows,\n columns,\n headers,\n}: VirtualizedTableProps<TableData>) {\n const virtuosoRef = useRef<TableVirtuosoHandle>(null);\n\n // Use a ref for these values because they are only needed for keyboard\n // focus interactions and setting them on state will lead to a significant\n // amount of unnecessary re-renders.\n const visibleRange = useRef({\n startIndex: 0,\n endIndex: 0,\n });\n const setVisibleRange: TableVirtuosoProps<TableData, unknown>['rangeChanged'] = (newVisibleRange) => {\n visibleRange.current = newVisibleRange;\n };\n\n const keyboardNav = useVirtualizedTableKeyboardNav({\n visibleRange: visibleRange,\n virtualTable: virtuosoRef,\n\n // We add 1 here for the header.\n maxRows: rows.length + 1,\n maxColumns: columns.length,\n });\n\n const getFocusState = (cellPosition: TableCellPosition): TableCellProps['focusState'] => {\n if (cellPosition.row === keyboardNav.activeCell.row && cellPosition.column === keyboardNav.activeCell.column) {\n return keyboardNav.isActive ? 'trigger-focus' : 'focus-next';\n }\n\n return 'none';\n };\n\n const VirtuosoTableComponents: TableComponents<TableData> = useMemo(() => {\n return {\n Scroller: VirtualizedTableContainer,\n Table: (props) => {\n return <InnerTable {...props} width={width} density={density} onKeyDown={keyboardNav.onTableKeyDown} />;\n },\n TableHead,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TableRow: ({ item, ...props }) => {\n const index = props['data-index'];\n const row = rows[index];\n if (!row) {\n return null;\n }\n\n const rowEventOpts: TableRowEventOpts = { id: row.id, index: row.index };\n\n return (\n <TableRow\n {...props}\n onClick={(e) => onRowClick(e, row.id)}\n density={density}\n onMouseOver={(e) => {\n onRowMouseOver?.(e, rowEventOpts);\n }}\n onMouseOut={(e) => {\n onRowMouseOut?.(e, rowEventOpts);\n }}\n />\n );\n },\n TableBody,\n };\n }, [density, keyboardNav.onTableKeyDown, onRowClick, onRowMouseOut, onRowMouseOver, rows, width]);\n\n return (\n <Box sx={{ width, height }}>\n <TableVirtuoso\n ref={virtuosoRef}\n totalCount={rows.length}\n components={VirtuosoTableComponents}\n // Note: this value is impacted by overscan. See this issue if overscan\n // is added.\n // https://github.com/petyosi/react-virtuoso/issues/118#issuecomment-642156138\n rangeChanged={setVisibleRange}\n fixedHeaderContent={() => {\n return (\n <>\n {headers.map((headerGroup) => {\n return (\n <TableRow key={headerGroup.id} density={density}>\n {headerGroup.headers.map((header, i, headers) => {\n const column = header.column;\n const position: TableCellPosition = {\n row: 0,\n column: i,\n };\n\n const isSorted = column.getIsSorted();\n const nextSorting = column.getNextSortingOrder();\n\n return (\n <TableHeaderCell\n key={header.id}\n onSort={column.getCanSort() ? column.getToggleSortingHandler() : undefined}\n sortDirection={typeof isSorted === 'string' ? isSorted : undefined}\n nextSortDirection={typeof nextSorting === 'string' ? nextSorting : undefined}\n width={column.getSize() || 'auto'}\n align={column.columnDef.meta?.align}\n variant=\"head\"\n density={density}\n description={column.columnDef.meta?.headerDescription}\n focusState={getFocusState(position)}\n onFocusTrigger={() => keyboardNav.onCellFocus(position)}\n isFirstColumn={i === 0}\n isLastColumn={i === headers.length - 1}\n >\n {flexRender(column.columnDef.header, header.getContext())}\n </TableHeaderCell>\n );\n })}\n </TableRow>\n );\n })}\n </>\n );\n }}\n itemContent={(index) => {\n const row = rows[index];\n if (!row) {\n return null;\n }\n\n return (\n <>\n {row.getVisibleCells().map((cell, i, cells) => {\n const position: TableCellPosition = {\n // Add 1 to the row index because the header is row 0\n row: index + 1,\n column: i,\n };\n\n const cellContext = cell.getContext();\n const cellRenderFn = cell.column.columnDef.cell;\n const cellContent = typeof cellRenderFn == 'function' ? cellRenderFn(cellContext) : null;\n\n const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;\n let description: string | undefined = undefined;\n if (typeof cellDescriptionDef === 'function') {\n // If the cell description is a function, set the value using\n // the function.\n description = cellDescriptionDef(cellContext);\n } else if (cellDescriptionDef && typeof cellContent === 'string') {\n // If the cell description is `true` AND the cell content is\n // a string (and thus viable as a `title` attribute), use the\n // cell content.\n description = cellContent;\n }\n\n return (\n <TableCell\n key={cell.id}\n width={cell.column.getSize() || 'auto'}\n align={cell.column.columnDef.meta?.align}\n density={density}\n focusState={getFocusState(position)}\n onFocusTrigger={() => keyboardNav.onCellFocus(position)}\n isFirstColumn={i === 0}\n isLastColumn={i === cells.length - 1}\n description={description}\n >\n {cellContent}\n </TableCell>\n );\n })}\n </>\n );\n }}\n />\n </Box>\n );\n}\n"],"names":["flexRender","Box","TableVirtuoso","useRef","useMemo","TableRow","TableBody","InnerTable","TableHead","TableHeaderCell","TableCell","VirtualizedTableContainer","useVirtualizedTableKeyboardNav","VirtualizedTable","width","height","density","onRowClick","onRowMouseOver","onRowMouseOut","rows","columns","headers","virtuosoRef","visibleRange","startIndex","endIndex","setVisibleRange","newVisibleRange","current","keyboardNav","virtualTable","maxRows","length","maxColumns","getFocusState","cellPosition","row","activeCell","column","isActive","VirtuosoTableComponents","Scroller","Table","props","onKeyDown","onTableKeyDown","item","index","rowEventOpts","id","onClick","e","onMouseOver","onMouseOut","sx","ref","totalCount","components","rangeChanged","fixedHeaderContent","map","headerGroup","header","i","position","isSorted","getIsSorted","nextSorting","getNextSortingOrder","onSort","getCanSort","getToggleSortingHandler","undefined","sortDirection","nextSortDirection","getSize","align","columnDef","meta","variant","description","headerDescription","focusState","onFocusTrigger","onCellFocus","isFirstColumn","isLastColumn","getContext","itemContent","getVisibleCells","cell","cells","cellContext","cellRenderFn","cellContent","cellDescriptionDef","cellDescription"],"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,SAAmCA,UAAU,QAAQ,uBAAuB,CAAC;AAC7E,SAASC,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,aAAa,QAAkE,gBAAgB,CAAC;AACzG,SAASC,MAAM,EAAEC,OAAO,QAAQ,OAAO,CAAC;AACxC,SAASC,QAAQ,QAAQ,YAAY,CAAC;AACtC,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AACpD,SAASC,SAAS,QAAwB,aAAa,CAAC;AACxD,SAASC,yBAAyB,QAAQ,6BAA6B,CAAC;AAExE,SAASC,8BAA8B,QAAQ,wCAAwC,CAAC;AAexF,6EAA6E;AAC7E,4EAA4E;AAC5E,mBAAmB;AACnB,OAAO,SAASC,gBAAgB,CAAY,EAC1CC,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,OAAO,CAAA,EACPC,UAAU,CAAA,EACVC,cAAc,CAAA,EACdC,aAAa,CAAA,EACbC,IAAI,CAAA,EACJC,OAAO,CAAA,EACPC,OAAO,CAAA,EAC0B,EAAE;IACnC,MAAMC,WAAW,GAAGpB,MAAM,CAAsB,IAAI,CAAC,AAAC;IAEtD,uEAAuE;IACvE,0EAA0E;IAC1E,oCAAoC;IACpC,MAAMqB,YAAY,GAAGrB,MAAM,CAAC;QAC1BsB,UAAU,EAAE,CAAC;QACbC,QAAQ,EAAE,CAAC;KACZ,CAAC,AAAC;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AS,AAAC;wBAChD,IAAI,OAAOuB,kBAAkB,KAAK,UAAU,EAAE;4BAC5C,6DAA6D;4BAC7D,gBAAgB;4BAChBf,WAAW,GAAGe,kBAAkB,CAACH,WAAW,CAAC,CAAC;wBAChD,OAAO,IAAIG,kBAAkB,IAAI,OAAOD,WAAW,KAAK,QAAQ,EAAE;4BAChE,4DAA4D;4BAC5D,6DAA6D;4BAC7D,gBAAgB;4BAChBd,WAAW,GAAGc,WAAW,CAAC;wBAC5B,CAAC;wBAED,qBACE,KAACrF,SAAS;4BAERI,KAAK,EAAE6E,IAAI,CAACpD,MAAM,CAACqC,OAAO,EAAE,IAAI,MAAM;4BACtCC,KAAK,EAAEc,CAAAA,IAA0B,GAA1BA,IAAI,CAACpD,MAAM,CAACuC,SAAS,CAACC,IAAI,cAA1BY,IAA0B,WAAO,GAAjCA,KAAAA,CAAiC,GAAjCA,IAA0B,CAAEd,KAAK;4BACxC7D,OAAO,EAAEA,OAAO;4BAChBmE,UAAU,EAAEhD,aAAa,CAAC8B,QAAQ,CAAC;4BACnCmB,cAAc,EAAE,IAAMtD,WAAW,CAACuD,WAAW,CAACpB,QAAQ,CAAC;4BACvDqB,aAAa,EAAEtB,CAAC,KAAK,CAAC;4BACtBuB,YAAY,EAAEvB,CAAC,KAAK4B,KAAK,CAAC3D,MAAM,GAAG,CAAC;4BACpCgD,WAAW,EAAEA,WAAW;sCAEvBc,WAAW;2BAVPJ,IAAI,CAACzC,EAAE,CAWF,CACZ;oBACJ,CAAC,CAAC;kBACD,CACH;YACJ,CAAC;UACD;MACE,CACN;AACJ,CAAC"}
@@ -1,7 +1,18 @@
1
1
  /// <reference types="react" />
2
2
  import { Theme } from '@mui/material';
3
- import { AccessorKeyColumnDef, ColumnDef, CoreOptions, RowData, RowSelectionState } from '@tanstack/react-table';
3
+ import { AccessorKeyColumnDef, CellContext, ColumnDef, CoreOptions, RowData, RowSelectionState, SortingState } from '@tanstack/react-table';
4
4
  export declare type TableDensity = 'compact' | 'standard';
5
+ export declare type SortDirection = 'asc' | 'desc' | undefined;
6
+ export declare type TableRowEventOpts = {
7
+ /**
8
+ * Unique identifier for the row.
9
+ */
10
+ id: string;
11
+ /**
12
+ * Index of the row in the original data.
13
+ */
14
+ index: number;
15
+ };
5
16
  export interface TableProps<TableData> {
6
17
  /**
7
18
  * Height of the table.
@@ -31,6 +42,18 @@ export interface TableProps<TableData> {
31
42
  * When `true`, the first column of the table will include checkboxes.
32
43
  */
33
44
  checkboxSelection?: boolean;
45
+ /**
46
+ * Determines the behavior of row selection.
47
+ *
48
+ * - `standard`: clicking a checkbox will toggle that rows's selected/unselected
49
+ * state and will not impact other rows.
50
+ * - `legend`: clicking a checkbox will "focus" that row by selecting it and
51
+ * unselecting other rows. Clicking a checkbox with a modifier key pressed,
52
+ * will change this behavior to behave like `standard`.
53
+ *
54
+ * @default 'standard'
55
+ */
56
+ rowSelectionVariant?: 'standard' | 'legend';
34
57
  /**
35
58
  * State of selected rows in the table when `checkboxSelection` is enabled.
36
59
  *
@@ -38,10 +61,29 @@ export interface TableProps<TableData> {
38
61
  * combination of this prop and `onRowSelectionChange`.
39
62
  */
40
63
  rowSelection?: RowSelectionState;
64
+ /**
65
+ * Callback fired when the mouse is moved over a table row.
66
+ */
67
+ onRowMouseOver?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;
68
+ /**
69
+ * Callback fired when the mouse is moved out of a table row.
70
+ */
71
+ onRowMouseOut?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;
72
+ /**
73
+ * State of the column sorting in the table.
74
+ *
75
+ * The column sorting is a controlled value that should be managed using a
76
+ * combination fo this prop and `onSortingChange`.
77
+ */
78
+ sorting?: SortingState;
41
79
  /**
42
80
  * Callback fired when the selected rows in the table changes.
43
81
  */
44
82
  onRowSelectionChange?: (rowSelection: RowSelectionState) => void;
83
+ /**
84
+ * Callback fired when the table sorting changes.
85
+ */
86
+ onSortingChange?: (sorting: SortingState) => void;
45
87
  /**
46
88
  * Function used to determine the unique identifier used for each row. This
47
89
  * value is used to key `rowSelection`. If this value is not set, the index
@@ -69,14 +111,40 @@ export declare function getTableCellLayout(theme: Theme, density: TableDensity,
69
111
  export declare type TableCellAlignment = 'left' | 'right' | 'center';
70
112
  declare module '@tanstack/table-core' {
71
113
  interface ColumnMeta<TData extends RowData, TValue> {
72
- align?: TableCellAlignment;
114
+ align?: TableColumnConfig<TData>['align'];
115
+ headerDescription?: TableColumnConfig<TData>['headerDescription'];
116
+ cellDescription?: TableColumnConfig<TData>['cellDescription'];
73
117
  }
74
118
  }
75
- export interface TableColumnConfig<TableData> extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell'> {
119
+ export interface TableColumnConfig<TableData> extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell' | 'sortingFn'> {
76
120
  /**
77
121
  * Text to display in the header for the column.
78
122
  */
79
123
  header: string;
124
+ /**
125
+ * Alignment of the content in the cell.
126
+ */
127
+ align?: TableCellAlignment;
128
+ /**
129
+ * Text to display when hovering over a cell. This can be useful for
130
+ * providing additional information about the column when the content is
131
+ * ellipsized to fit in the space.
132
+ *
133
+ * If set to `true`, it will use the value generated by the `cell` prop if it
134
+ * can be treated as a string.
135
+ */
136
+ cellDescription?: ((props: CellContext<TableData, any>) => string) | boolean | undefined;
137
+ /**
138
+ * When `true`, the column will be sortable.
139
+ * @default false
140
+ */
141
+ enableSorting?: boolean;
142
+ /**
143
+ * Text to display when hovering over the header text. This can be useful for
144
+ * providing additional information about the column when you want to keep the
145
+ * header text relatively short to manage the column width.
146
+ */
147
+ headerDescription?: string;
80
148
  /**
81
149
  * Width of the column when rendered in a table. It should be a number in pixels
82
150
  * or "auto" to allow the table to automatically adjust the width to fill
@@ -84,10 +152,6 @@ export interface TableColumnConfig<TableData> extends Pick<AccessorKeyColumnDef<
84
152
  * @default 'auto'
85
153
  */
86
154
  width?: number | 'auto';
87
- /**
88
- * Alignment of the content in the cell.
89
- */
90
- align?: TableCellAlignment;
91
155
  }
92
156
  /**
93
157
  * Takes in a perses table column and transforms it into a tanstack column.
@@ -1 +1 @@
1
- {"version":3,"file":"table-model.d.ts","sourceRoot":"","sources":["../../../src/Table/model/table-model.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAGjH,oBAAY,YAAY,GAAG,SAAS,GAAG,UAAU,CAAC;AAElD,MAAM,WAAW,UAAU,CAAC,SAAS;IACnC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,EAAE,SAAS,EAAE,CAAC;IAElB;;;;OAIG;IACH,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;IAE7C;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEjE;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;IAE9C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,MAAM,CAAC;CACnD;AAWD,aAAK,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;IACrG,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,aAAK,sBAAsB,GAAG;IAC5B,YAAY,CAAC,EAAE,OA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O,CAAC;IAExB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAI3B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,mCA0CrG"}
@@ -52,7 +52,7 @@ function calculateTableCellHeight(lineHeight, paddingY) {
52
52
  /**
53
53
  * Takes in a perses table column and transforms it into a tanstack column.
54
54
  */ export function persesColumnsToTanstackColumns(columns) {
55
- const tableCols = columns.map(({ width , align , ...otherProps })=>{
55
+ const tableCols = columns.map(({ width , align , headerDescription , cellDescription , enableSorting , ...otherProps })=>{
56
56
  // Tanstack Table does not support an "auto" value to naturally size to fit
57
57
  // the space in a table. We translate our custom "auto" setting to 0 size
58
58
  // for these columns, so it is easy to fall back to auto when rendering.
@@ -70,10 +70,14 @@ function calculateTableCellHeight(lineHeight, paddingY) {
70
70
  const result = {
71
71
  ...otherProps,
72
72
  ...sizeProps,
73
+ // Default sorting to false, so it is very explicitly set per column.
74
+ enableSorting: !!enableSorting,
73
75
  // Open-ended store for extra metadata in TanStack Table, so you can bake
74
76
  // in your own features.
75
77
  meta: {
76
- align
78
+ align,
79
+ headerDescription,
80
+ cellDescription
77
81
  }
78
82
  };
79
83
  return result;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Table/model/table-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 { AccessorKeyColumnDef, ColumnDef, CoreOptions, RowData, RowSelectionState } from '@tanstack/react-table';\nimport { CSSProperties } from 'react';\n\nexport type TableDensity = 'compact' | 'standard';\n\nexport interface TableProps<TableData> {\n /**\n * Height of the table.\n */\n height: number;\n\n /**\n * Width of the table.\n */\n width: number;\n\n /**\n * Array of data to render in the table. Each entry in the array will be\n * rendered as a row in the table.\n */\n data: TableData[];\n\n /**\n * Array of column configuration for the table. Each entry in the array will\n * be rendered as a column header and impact the rendering of cells within\n * table rows.\n */\n columns: Array<TableColumnConfig<TableData>>;\n\n /**\n * The density of the table layout. This impacts the size and space taken up\n * by content in the table (e.g. font size, padding).\n */\n density?: TableDensity;\n\n /**\n * When `true`, the first column of the table will include checkboxes.\n */\n checkboxSelection?: boolean;\n\n /**\n * State of selected rows in the table when `checkboxSelection` is enabled.\n *\n * Selected row state is a controlled value that should be managed using a\n * combination of this prop and `onRowSelectionChange`.\n */\n rowSelection?: RowSelectionState;\n\n /**\n * Callback fired when the selected rows in the table changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n\n /**\n * Function used to determine the unique identifier used for each row. This\n * value is used to key `rowSelection`. If this value is not set, the index\n * is used as the unique identifier.\n */\n getRowId?: CoreOptions<TableData>['getRowId'];\n\n /**\n * Function used to determine the color of the checkbox when `checkboxSelection`\n * is enabled. If not set, a default color is used.\n */\n getCheckboxColor?: (rowData: TableData) => string;\n}\n\nfunction calculateTableCellHeight(lineHeight: CSSProperties['lineHeight'], paddingY: string): number {\n // Doing a bunch of math to enforce height to avoid weirdness with mismatched\n // heights based on customization of cell contents.\n const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight ?? 0;\n const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;\n\n return lineHeightNum + verticalPaddingNum * 2;\n}\n\ntype TableCellLayout = NonNullable<Pick<React.CSSProperties, 'padding' | 'fontSize' | 'lineHeight'>> & {\n height: number;\n};\n\ntype GetTableCellLayoutOpts = {\n isLastColumn?: boolean;\n isFirstColumn?: boolean;\n};\n\n/**\n * Returns the properties to lay out the content of table cells based on the\n * theme and density.\n */\nexport function getTableCellLayout(\n theme: Theme,\n density: TableDensity,\n { isLastColumn, isFirstColumn }: GetTableCellLayoutOpts = {}\n): TableCellLayout {\n if (density === 'compact') {\n const paddingY = theme.spacing(0.5);\n\n const basePaddingX = theme.spacing(0.5);\n const edgePaddingX = theme.spacing(1);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n\n const lineHeight = theme.typography.body2.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body2.fontSize,\n lineHeight: lineHeight,\n };\n }\n\n // standard density\n const paddingY = theme.spacing(1);\n const basePaddingX = theme.spacing(1.25);\n const edgePaddingX = theme.spacing(2);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n const lineHeight = theme.typography.body1.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body1.fontSize,\n lineHeight: lineHeight,\n };\n}\n\nexport type TableCellAlignment = 'left' | 'right' | 'center';\n\n// Overrides of meta value, so it can have a meaningful type in our code instead\n// of `any`. Putting this in the model instead of a separate .d.ts file because\n// I couldn't get it to work properly that way and punted on figuring it out\n// after trying several things.\ndeclare module '@tanstack/table-core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableCellAlignment;\n }\n}\n\n// Only exposing a very simplified version of the very extensive column definitions\n// possible with tanstack table to make it easier for us to control rendering\n// and functionality.\nexport interface TableColumnConfig<TableData>\n // Any needed to work around some typing issues with tanstack query.\n // https://github.com/TanStack/table/issues/4241\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell'> {\n /**\n * Text to display in the header for the column.\n */\n header: string;\n\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. Adding a custom setting to manage this ourselves.\n /**\n * Width of the column when rendered in a table. It should be a number in pixels\n * or \"auto\" to allow the table to automatically adjust the width to fill\n * space.\n * @default 'auto'\n */\n width?: number | 'auto';\n\n /**\n * Alignment of the content in the cell.\n */\n align?: TableCellAlignment;\n}\n\n/**\n * Takes in a perses table column and transforms it into a tanstack column.\n */\nexport function persesColumnsToTanstackColumns<TableData>(columns: Array<TableColumnConfig<TableData>>) {\n const tableCols: Array<ColumnDef<TableData>> = columns.map(({ width, align, ...otherProps }) => {\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. We translate our custom \"auto\" setting to 0 size\n // for these columns, so it is easy to fall back to auto when rendering.\n // Taking from a recommendation in this github discussion:\n // https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326\n const sizeProps =\n width === 'auto' || width === undefined\n ? {\n // All zero values are used as shorthand for \"auto\" when rendering\n // because it makes it easy to fall back. (e.g. `row.size || \"auto\"`)\n size: 0,\n minSize: 0,\n maxSize: 0,\n }\n : {\n size: width,\n };\n\n const result = {\n ...otherProps,\n ...sizeProps,\n\n // Open-ended store for extra metadata in TanStack Table, so you can bake\n // in your own features.\n meta: {\n align,\n },\n };\n\n return result;\n });\n\n return tableCols;\n}\n"],"names":["calculateTableCellHeight","lineHeight","paddingY","lineHeightNum","parseInt","verticalPaddingNum","getTableCellLayout","theme","density","isLastColumn","isFirstColumn","spacing","basePaddingX","edgePaddingX","paddingLeft","paddingRight","typography","body2","padding","height","fontSize","body1","persesColumnsToTanstackColumns","columns","tableCols","map","width","align","otherProps","sizeProps","undefined","size","minSize","maxSize","result","meta"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE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,0DAA0D;QAC1D,+EAA+E;QAC/E,MAAMC,SAAS,GACbH,KAAK,KAAK,MAAM,IAAIA,KAAK,KAAKI,SAAS,GACnC;YACE,kEAAkE;YAClE,qEAAqE;YACrEC,IAAI,EAAE,CAAC;YACPC,OAAO,EAAE,CAAC;YACVC,OAAO,EAAE,CAAC;SACX,GACD;YACEF,IAAI,EAAEL,KAAK;SACZ,AAAC;QAER,MAAMQ,MAAM,GAAG;YACb,GAAGN,UAAU;YACb,GAAGC,SAAS;YAEZ,yEAAyE;YACzE,wBAAwB;YACxBM,IAAI,EAAE;gBACJR,KAAK;aACN;SACF,AAAC;QAEF,OAAOO,MAAM,CAAC;IAChB,CAAC,CAAC,AAAC;IAEH,OAAOV,SAAS,CAAC;AACnB,CAAC"}
1
+ {"version":3,"sources":["../../../src/Table/model/table-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 {\n AccessorKeyColumnDef,\n CellContext,\n ColumnDef,\n CoreOptions,\n RowData,\n RowSelectionState,\n SortingState,\n} from '@tanstack/react-table';\nimport { CSSProperties } from 'react';\n\nexport type TableDensity = 'compact' | 'standard';\nexport type SortDirection = 'asc' | 'desc' | undefined;\n\nexport type TableRowEventOpts = {\n /**\n * Unique identifier for the row.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface TableProps<TableData> {\n /**\n * Height of the table.\n */\n height: number;\n\n /**\n * Width of the table.\n */\n width: number;\n\n /**\n * Array of data to render in the table. Each entry in the array will be\n * rendered as a row in the table.\n */\n data: TableData[];\n\n /**\n * Array of column configuration for the table. Each entry in the array will\n * be rendered as a column header and impact the rendering of cells within\n * table rows.\n */\n columns: Array<TableColumnConfig<TableData>>;\n\n /**\n * The density of the table layout. This impacts the size and space taken up\n * by content in the table (e.g. font size, padding).\n */\n density?: TableDensity;\n\n /**\n * When `true`, the first column of the table will include checkboxes.\n */\n checkboxSelection?: boolean;\n\n /**\n * Determines the behavior of row selection.\n *\n * - `standard`: clicking a checkbox will toggle that rows's selected/unselected\n * state and will not impact other rows.\n * - `legend`: clicking a checkbox will \"focus\" that row by selecting it and\n * unselecting other rows. Clicking a checkbox with a modifier key pressed,\n * will change this behavior to behave like `standard`.\n *\n * @default 'standard'\n */\n rowSelectionVariant?: 'standard' | 'legend';\n\n /**\n * State of selected rows in the table when `checkboxSelection` is enabled.\n *\n * Selected row state is a controlled value that should be managed using a\n * combination of this prop and `onRowSelectionChange`.\n */\n rowSelection?: RowSelectionState;\n\n /**\n * Callback fired when the mouse is moved over a table row.\n */\n onRowMouseOver?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * Callback fired when the mouse is moved out of a table row.\n */\n onRowMouseOut?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * State of the column sorting in the table.\n *\n * The column sorting is a controlled value that should be managed using a\n * combination fo this prop and `onSortingChange`.\n */\n sorting?: SortingState;\n\n /**\n * Callback fired when the selected rows in the table changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n\n /**\n * Callback fired when the table sorting changes.\n */\n onSortingChange?: (sorting: SortingState) => void;\n\n /**\n * Function used to determine the unique identifier used for each row. This\n * value is used to key `rowSelection`. If this value is not set, the index\n * is used as the unique identifier.\n */\n getRowId?: CoreOptions<TableData>['getRowId'];\n\n /**\n * Function used to determine the color of the checkbox when `checkboxSelection`\n * is enabled. If not set, a default color is used.\n */\n getCheckboxColor?: (rowData: TableData) => string;\n}\n\nfunction calculateTableCellHeight(lineHeight: CSSProperties['lineHeight'], paddingY: string): number {\n // Doing a bunch of math to enforce height to avoid weirdness with mismatched\n // heights based on customization of cell contents.\n const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight ?? 0;\n const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;\n\n return lineHeightNum + verticalPaddingNum * 2;\n}\n\ntype TableCellLayout = NonNullable<Pick<React.CSSProperties, 'padding' | 'fontSize' | 'lineHeight'>> & {\n height: number;\n};\n\ntype GetTableCellLayoutOpts = {\n isLastColumn?: boolean;\n isFirstColumn?: boolean;\n};\n\n/**\n * Returns the properties to lay out the content of table cells based on the\n * theme and density.\n */\nexport function getTableCellLayout(\n theme: Theme,\n density: TableDensity,\n { isLastColumn, isFirstColumn }: GetTableCellLayoutOpts = {}\n): TableCellLayout {\n if (density === 'compact') {\n const paddingY = theme.spacing(0.5);\n\n const basePaddingX = theme.spacing(0.5);\n const edgePaddingX = theme.spacing(1);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n\n const lineHeight = theme.typography.body2.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body2.fontSize,\n lineHeight: lineHeight,\n };\n }\n\n // standard density\n const paddingY = theme.spacing(1);\n const basePaddingX = theme.spacing(1.25);\n const edgePaddingX = theme.spacing(2);\n const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n const lineHeight = theme.typography.body1.lineHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: calculateTableCellHeight(lineHeight, paddingY),\n fontSize: theme.typography.body1.fontSize,\n lineHeight: lineHeight,\n };\n}\n\nexport type TableCellAlignment = 'left' | 'right' | 'center';\n\n// Overrides of meta value, so it can have a meaningful type in our code instead\n// of `any`. Putting this in the model instead of a separate .d.ts file because\n// I couldn't get it to work properly that way and punted on figuring it out\n// after trying several things.\ndeclare module '@tanstack/table-core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnConfig<TData>['align'];\n headerDescription?: TableColumnConfig<TData>['headerDescription'];\n cellDescription?: TableColumnConfig<TData>['cellDescription'];\n }\n}\n\n// Only exposing a very simplified version of the very extensive column definitions\n// possible with tanstack table to make it easier for us to control rendering\n// and functionality.\nexport interface TableColumnConfig<TableData>\n // Any needed to work around some typing issues with tanstack query.\n // https://github.com/TanStack/table/issues/4241\n // TODO: revisit issue thread and see if there are any workarounds we can\n // use.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell' | 'sortingFn'> {\n /**\n * Text to display in the header for the column.\n */\n header: string;\n\n /**\n * Alignment of the content in the cell.\n */\n align?: TableCellAlignment;\n\n /**\n * Text to display when hovering over a cell. This can be useful for\n * providing additional information about the column when the content is\n * ellipsized to fit in the space.\n *\n * If set to `true`, it will use the value generated by the `cell` prop if it\n * can be treated as a string.\n */\n // `any` needed for same reason as no-explicit-any higher up in this type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n cellDescription?: ((props: CellContext<TableData, any>) => string) | boolean | undefined;\n\n /**\n * When `true`, the column will be sortable.\n * @default false\n */\n enableSorting?: boolean;\n\n /**\n * Text to display when hovering over the header text. This can be useful for\n * providing additional information about the column when you want to keep the\n * header text relatively short to manage the column width.\n */\n headerDescription?: string;\n\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. Adding a custom setting to manage this ourselves.\n /**\n * Width of the column when rendered in a table. It should be a number in pixels\n * or \"auto\" to allow the table to automatically adjust the width to fill\n * space.\n * @default 'auto'\n */\n width?: number | 'auto';\n}\n\n/**\n * Takes in a perses table column and transforms it into a tanstack column.\n */\nexport function persesColumnsToTanstackColumns<TableData>(columns: Array<TableColumnConfig<TableData>>) {\n const tableCols: Array<ColumnDef<TableData>> = columns.map(\n ({ width, align, headerDescription, cellDescription, enableSorting, ...otherProps }) => {\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. We translate our custom \"auto\" setting to 0 size\n // for these columns, so it is easy to fall back to auto when rendering.\n // Taking from a recommendation in this github discussion:\n // https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326\n const sizeProps =\n width === 'auto' || width === undefined\n ? {\n // All zero values are used as shorthand for \"auto\" when rendering\n // because it makes it easy to fall back. (e.g. `row.size || \"auto\"`)\n size: 0,\n minSize: 0,\n maxSize: 0,\n }\n : {\n size: width,\n };\n\n const result = {\n ...otherProps,\n ...sizeProps,\n\n // Default sorting to false, so it is very explicitly set per column.\n enableSorting: !!enableSorting,\n\n // Open-ended store for extra metadata in TanStack Table, so you can bake\n // in your own features.\n meta: {\n align,\n headerDescription,\n cellDescription,\n },\n };\n\n return result;\n }\n );\n\n return tableCols;\n}\n"],"names":["calculateTableCellHeight","lineHeight","paddingY","lineHeightNum","parseInt","verticalPaddingNum","getTableCellLayout","theme","density","isLastColumn","isFirstColumn","spacing","basePaddingX","edgePaddingX","paddingLeft","paddingRight","typography","body2","padding","height","fontSize","body1","persesColumnsToTanstackColumns","columns","tableCols","map","width","align","headerDescription","cellDescription","enableSorting","otherProps","sizeProps","undefined","size","minSize","maxSize","result","meta"],"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;AA+HjC,SAASA,wBAAwB,CAACC,UAAuC,EAAEC,QAAgB,EAAU;IACnG,6EAA6E;IAC7E,mDAAmD;IACnD,MAAMC,aAAa,GAAG,OAAOF,UAAU,KAAK,QAAQ,GAAGG,QAAQ,CAACH,UAAU,EAA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C;QAER,MAAMW,MAAM,GAAG;YACb,GAAGN,UAAU;YACb,GAAGC,SAAS;YAEZ,qEAAqE;YACrEF,aAAa,EAAE,CAAC,CAACA,aAAa;YAE9B,yEAAyE;YACzE,wBAAwB;YACxBQ,IAAI,EAAE;gBACJX,KAAK;gBACLC,iBAAiB;gBACjBC,eAAe;aAChB;SACF,AAAC;QAEF,OAAOQ,MAAM,CAAC;IAChB,CAAC,CACF,AAAC;IAEF,OAAOb,SAAS,CAAC;AACnB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
+ import { UnitOptions } from '@perses-dev/core';
2
3
  import { ECharts as EChartsInstance } from 'echarts/core';
3
- import { EChartsDataFormat, UnitOptions } from '../model';
4
+ import { EChartsDataFormat } from '../model';
4
5
  import { CursorCoordinates } from './tooltip-model';
5
6
  export interface TimeSeriesTooltipProps {
6
7
  chartRef: React.MutableRefObject<EChartsInstance | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"TimeSeriesTooltip.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TimeSeriesTooltip.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI1D,OAAO,EACL,iBAAiB,EAOlB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACrC;AAED,eAAO,MAAM,iBAAiB,8DAiF5B,CAAC"}
1
+ {"version":3,"file":"TimeSeriesTooltip.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TimeSeriesTooltip.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI7C,OAAO,EACL,iBAAiB,EAOlB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACrC;AAED,eAAO,MAAM,iBAAiB,8DAkF5B,CAAC"}
@@ -65,7 +65,8 @@ export const TimeSeriesTooltip = /*#__PURE__*/ memo(function TimeSeriesTooltip({
65
65
  visibility: 'visible',
66
66
  opacity: 1,
67
67
  transition: 'all 0.1s ease-out',
68
- zIndex: theme.zIndex.tooltip,
68
+ // Ensure pinned tooltip shows behind edit panel drawer and sticky header
69
+ zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,
69
70
  overflow: 'hidden',
70
71
  '&:hover': {
71
72
  overflowY: 'auto'