@perses-dev/components 0.0.0-snapshot-saving-defaults-refinements-1b25cec → 0.0.0-snapshot-time-chart-rewrite-4667058

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 (307) 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 +5 -3
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +10 -4
  6. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  7. package/dist/ContentWithLegend/model/content-with-legend-model.js +27 -8
  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/Drawer/Drawer.js +1 -1
  16. package/dist/Drawer/Drawer.js.map +1 -1
  17. package/dist/EChart/EChart.d.ts +2 -1
  18. package/dist/EChart/EChart.d.ts.map +1 -1
  19. package/dist/EChart/EChart.js +15 -3
  20. package/dist/EChart/EChart.js.map +1 -1
  21. package/dist/GaugeChart/GaugeChart.d.ts +2 -2
  22. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  23. package/dist/GaugeChart/GaugeChart.js +7 -5
  24. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  25. package/dist/Legend/CompactLegend.d.ts +4 -2
  26. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  27. package/dist/Legend/CompactLegend.js +6 -3
  28. package/dist/Legend/CompactLegend.js.map +1 -1
  29. package/dist/Legend/Legend.d.ts +17 -3
  30. package/dist/Legend/Legend.d.ts.map +1 -1
  31. package/dist/Legend/Legend.js +7 -4
  32. package/dist/Legend/Legend.js.map +1 -1
  33. package/dist/Legend/ListLegend.d.ts +4 -2
  34. package/dist/Legend/ListLegend.d.ts.map +1 -1
  35. package/dist/Legend/ListLegend.js +6 -5
  36. package/dist/Legend/ListLegend.js.map +1 -1
  37. package/dist/Legend/ListLegendItem.d.ts +16 -3
  38. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  39. package/dist/Legend/ListLegendItem.js +17 -5
  40. package/dist/Legend/ListLegendItem.js.map +1 -1
  41. package/dist/Legend/TableLegend.d.ts +6 -3
  42. package/dist/Legend/TableLegend.d.ts.map +1 -1
  43. package/dist/Legend/TableLegend.js +17 -3
  44. package/dist/Legend/TableLegend.js.map +1 -1
  45. package/dist/Legend/index.d.ts +1 -0
  46. package/dist/Legend/index.d.ts.map +1 -1
  47. package/dist/Legend/index.js +1 -0
  48. package/dist/Legend/index.js.map +1 -1
  49. package/dist/Legend/legend-model.d.ts +24 -0
  50. package/dist/Legend/legend-model.d.ts.map +1 -0
  51. package/dist/Legend/legend-model.js +19 -0
  52. package/dist/Legend/legend-model.js.map +1 -0
  53. package/dist/LineChart/LineChart.d.ts +6 -11
  54. package/dist/LineChart/LineChart.d.ts.map +1 -1
  55. package/dist/LineChart/LineChart.js +36 -9
  56. package/dist/LineChart/LineChart.js.map +1 -1
  57. package/dist/LineChart/index.d.ts +0 -1
  58. package/dist/LineChart/index.d.ts.map +1 -1
  59. package/dist/LineChart/index.js.map +1 -1
  60. package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  61. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  62. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +12 -0
  63. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts.map +1 -0
  64. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +45 -0
  65. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -0
  66. package/dist/RefreshIntervalPicker/index.d.ts +2 -0
  67. package/dist/RefreshIntervalPicker/index.d.ts.map +1 -0
  68. package/dist/{model/units → RefreshIntervalPicker}/index.js +1 -3
  69. package/dist/RefreshIntervalPicker/index.js.map +1 -0
  70. package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts +36 -0
  71. package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts.map +1 -0
  72. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +65 -0
  73. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -0
  74. package/dist/SettingsAutocomplete/index.d.ts +2 -0
  75. package/dist/SettingsAutocomplete/index.d.ts.map +1 -0
  76. package/dist/{model/units/constants.js → SettingsAutocomplete/index.js} +2 -4
  77. package/dist/SettingsAutocomplete/index.js.map +1 -0
  78. package/dist/StatChart/StatChart.d.ts +3 -2
  79. package/dist/StatChart/StatChart.d.ts.map +1 -1
  80. package/dist/StatChart/StatChart.js +75 -22
  81. package/dist/StatChart/StatChart.js.map +1 -1
  82. package/dist/StatChart/calculateFontSize.d.ts +14 -0
  83. package/dist/StatChart/calculateFontSize.d.ts.map +1 -0
  84. package/dist/StatChart/calculateFontSize.js +47 -0
  85. package/dist/StatChart/calculateFontSize.js.map +1 -0
  86. package/dist/Table/InnerTable.js +3 -3
  87. package/dist/Table/InnerTable.js.map +1 -1
  88. package/dist/Table/Table.d.ts +1 -1
  89. package/dist/Table/Table.d.ts.map +1 -1
  90. package/dist/Table/Table.js +58 -10
  91. package/dist/Table/Table.js.map +1 -1
  92. package/dist/Table/TableCell.d.ts +16 -3
  93. package/dist/Table/TableCell.d.ts.map +1 -1
  94. package/dist/Table/TableCell.js +13 -5
  95. package/dist/Table/TableCell.js.map +1 -1
  96. package/dist/Table/TableCheckbox.js +1 -1
  97. package/dist/Table/TableCheckbox.js.map +1 -1
  98. package/dist/Table/TableHeaderCell.d.ts +23 -0
  99. package/dist/Table/TableHeaderCell.d.ts.map +1 -0
  100. package/dist/Table/TableHeaderCell.js +53 -0
  101. package/dist/Table/TableHeaderCell.js.map +1 -0
  102. package/dist/Table/TableRow.d.ts.map +1 -1
  103. package/dist/Table/TableRow.js +3 -3
  104. package/dist/Table/TableRow.js.map +1 -1
  105. package/dist/Table/VirtualizedTable.d.ts +3 -3
  106. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  107. package/dist/Table/VirtualizedTable.js +51 -10
  108. package/dist/Table/VirtualizedTable.js.map +1 -1
  109. package/dist/Table/model/table-model.d.ts +81 -3
  110. package/dist/Table/model/table-model.d.ts.map +1 -1
  111. package/dist/Table/model/table-model.js +22 -7
  112. package/dist/Table/model/table-model.js.map +1 -1
  113. package/dist/TimeChart/TimeChart.d.ts +23 -0
  114. package/dist/TimeChart/TimeChart.d.ts.map +1 -0
  115. package/dist/TimeChart/TimeChart.js +314 -0
  116. package/dist/TimeChart/TimeChart.js.map +1 -0
  117. package/dist/TimeChart/index.d.ts +2 -0
  118. package/dist/TimeChart/index.d.ts.map +1 -0
  119. package/dist/{LegendOptionsEditor → TimeChart}/index.js +1 -1
  120. package/dist/TimeChart/index.js.map +1 -0
  121. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.d.ts → LineChartTooltip.d.ts} +5 -4
  122. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -0
  123. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +7 -6
  124. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -0
  125. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +16 -0
  126. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -0
  127. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +76 -0
  128. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -0
  129. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +2 -2
  130. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
  131. package/dist/TimeSeriesTooltip/TooltipHeader.js +10 -8
  132. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  133. package/dist/TimeSeriesTooltip/index.d.ts +2 -1
  134. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  135. package/dist/TimeSeriesTooltip/index.js +2 -1
  136. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  137. package/dist/TimeSeriesTooltip/nearby-series.d.ts +23 -4
  138. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  139. package/dist/TimeSeriesTooltip/nearby-series.js +175 -17
  140. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
  142. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  143. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  144. package/dist/TimeSeriesTooltip/utils.d.ts +25 -0
  145. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  146. package/dist/TimeSeriesTooltip/utils.js +29 -1
  147. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  148. package/dist/UnitSelector/UnitSelector.d.ts +1 -1
  149. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
  150. package/dist/UnitSelector/UnitSelector.js +11 -24
  151. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  152. package/dist/YAxisLabel.js +1 -1
  153. package/dist/YAxisLabel.js.map +1 -1
  154. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +5 -3
  155. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +28 -9
  156. package/dist/cjs/Drawer/Drawer.js +1 -1
  157. package/dist/cjs/EChart/EChart.js +22 -5
  158. package/dist/cjs/GaugeChart/GaugeChart.js +7 -5
  159. package/dist/cjs/Legend/CompactLegend.js +7 -4
  160. package/dist/cjs/Legend/Legend.js +8 -5
  161. package/dist/cjs/Legend/ListLegend.js +7 -6
  162. package/dist/cjs/Legend/ListLegendItem.js +17 -5
  163. package/dist/cjs/Legend/TableLegend.js +17 -3
  164. package/dist/cjs/Legend/index.js +1 -0
  165. package/dist/cjs/{model/units/types.js → Legend/legend-model.js} +7 -10
  166. package/dist/cjs/LineChart/LineChart.js +35 -47
  167. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  168. package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +51 -0
  169. package/dist/cjs/{model/units → RefreshIntervalPicker}/index.js +1 -3
  170. package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +66 -0
  171. package/dist/cjs/SettingsAutocomplete/index.js +28 -0
  172. package/dist/cjs/StatChart/StatChart.js +82 -24
  173. package/dist/cjs/StatChart/calculateFontSize.js +51 -0
  174. package/dist/cjs/Table/InnerTable.js +3 -3
  175. package/dist/cjs/Table/Table.js +57 -9
  176. package/dist/cjs/Table/TableCell.js +13 -5
  177. package/dist/cjs/Table/TableCheckbox.js +1 -1
  178. package/dist/cjs/Table/TableHeaderCell.js +59 -0
  179. package/dist/cjs/Table/TableRow.js +2 -2
  180. package/dist/cjs/Table/VirtualizedTable.js +51 -10
  181. package/dist/cjs/Table/model/table-model.js +22 -7
  182. package/dist/cjs/TimeChart/TimeChart.js +320 -0
  183. package/dist/cjs/{LegendOptionsEditor → TimeChart}/index.js +1 -1
  184. package/dist/cjs/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +7 -45
  185. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +87 -0
  186. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +10 -8
  187. package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
  188. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +171 -17
  189. package/dist/cjs/TimeSeriesTooltip/utils.js +35 -3
  190. package/dist/cjs/UnitSelector/UnitSelector.js +15 -28
  191. package/dist/cjs/YAxisLabel.js +1 -1
  192. package/dist/cjs/index.js +3 -1
  193. package/dist/cjs/model/index.js +1 -2
  194. package/dist/cjs/model/timeOption.js +16 -0
  195. package/dist/cjs/{model/units/constants.js → theme/component-overrides/paper.js} +9 -5
  196. package/dist/cjs/theme/palette/background.js +2 -2
  197. package/dist/cjs/theme/theme.js +2 -0
  198. package/dist/cjs/utils/axis.js +58 -0
  199. package/dist/cjs/{LineChart/utils.js → utils/chart-actions.js} +9 -47
  200. package/dist/cjs/utils/format.js +47 -1
  201. package/dist/cjs/utils/index.js +3 -1
  202. package/dist/cjs/utils/theme-gen.js +44 -2
  203. package/dist/index.d.ts +3 -1
  204. package/dist/index.d.ts.map +1 -1
  205. package/dist/index.js +3 -1
  206. package/dist/index.js.map +1 -1
  207. package/dist/model/graph.d.ts +20 -3
  208. package/dist/model/graph.d.ts.map +1 -1
  209. package/dist/model/graph.js.map +1 -1
  210. package/dist/model/index.d.ts +1 -2
  211. package/dist/model/index.d.ts.map +1 -1
  212. package/dist/model/index.js +1 -2
  213. package/dist/model/index.js.map +1 -1
  214. package/dist/model/theme.d.ts +4 -6
  215. package/dist/model/theme.d.ts.map +1 -1
  216. package/dist/model/theme.js.map +1 -1
  217. package/dist/model/timeOption.d.ts +6 -0
  218. package/dist/model/timeOption.d.ts.map +1 -0
  219. package/dist/model/{units/types.js → timeOption.js} +2 -9
  220. package/dist/model/timeOption.js.map +1 -0
  221. package/dist/theme/component-overrides/paper.d.ts +3 -0
  222. package/dist/theme/component-overrides/paper.d.ts.map +1 -0
  223. package/dist/theme/component-overrides/paper.js +21 -0
  224. package/dist/theme/component-overrides/paper.js.map +1 -0
  225. package/dist/theme/palette/background.js +2 -2
  226. package/dist/theme/palette/background.js.map +1 -1
  227. package/dist/theme/theme.d.ts.map +1 -1
  228. package/dist/theme/theme.js +2 -0
  229. package/dist/theme/theme.js.map +1 -1
  230. package/dist/utils/axis.d.ts +14 -0
  231. package/dist/utils/axis.d.ts.map +1 -0
  232. package/dist/utils/axis.js +45 -0
  233. package/dist/utils/axis.js.map +1 -0
  234. package/dist/utils/chart-actions.d.ts +18 -0
  235. package/dist/utils/chart-actions.d.ts.map +1 -0
  236. package/dist/utils/chart-actions.js +52 -0
  237. package/dist/utils/chart-actions.js.map +1 -0
  238. package/dist/utils/format.d.ts +6 -0
  239. package/dist/utils/format.d.ts.map +1 -1
  240. package/dist/utils/format.js +47 -0
  241. package/dist/utils/format.js.map +1 -1
  242. package/dist/utils/index.d.ts +3 -1
  243. package/dist/utils/index.d.ts.map +1 -1
  244. package/dist/utils/index.js +3 -1
  245. package/dist/utils/index.js.map +1 -1
  246. package/dist/utils/theme-gen.d.ts.map +1 -1
  247. package/dist/utils/theme-gen.js +38 -1
  248. package/dist/utils/theme-gen.js.map +1 -1
  249. package/package.json +5 -9
  250. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts +0 -8
  251. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +0 -1
  252. package/dist/LegendOptionsEditor/LegendOptionsEditor.js +0 -109
  253. package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +0 -1
  254. package/dist/LegendOptionsEditor/index.d.ts +0 -2
  255. package/dist/LegendOptionsEditor/index.d.ts.map +0 -1
  256. package/dist/LegendOptionsEditor/index.js.map +0 -1
  257. package/dist/LineChart/utils.d.ts +0 -30
  258. package/dist/LineChart/utils.d.ts.map +0 -1
  259. package/dist/LineChart/utils.js +0 -90
  260. package/dist/LineChart/utils.js.map +0 -1
  261. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +0 -1
  262. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +0 -1
  263. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +0 -115
  264. package/dist/cjs/model/legend.js +0 -102
  265. package/dist/cjs/model/units/bytes.js +0 -84
  266. package/dist/cjs/model/units/decimal.js +0 -62
  267. package/dist/cjs/model/units/percent.js +0 -73
  268. package/dist/cjs/model/units/time.js +0 -105
  269. package/dist/cjs/model/units/units.js +0 -101
  270. package/dist/cjs/model/units/utils.js +0 -42
  271. package/dist/model/legend.d.ts +0 -36
  272. package/dist/model/legend.d.ts.map +0 -1
  273. package/dist/model/legend.js +0 -81
  274. package/dist/model/legend.js.map +0 -1
  275. package/dist/model/units/bytes.d.ts +0 -13
  276. package/dist/model/units/bytes.d.ts.map +0 -1
  277. package/dist/model/units/bytes.js +0 -66
  278. package/dist/model/units/bytes.js.map +0 -1
  279. package/dist/model/units/constants.d.ts +0 -2
  280. package/dist/model/units/constants.d.ts.map +0 -1
  281. package/dist/model/units/constants.js.map +0 -1
  282. package/dist/model/units/decimal.d.ts +0 -13
  283. package/dist/model/units/decimal.d.ts.map +0 -1
  284. package/dist/model/units/decimal.js +0 -49
  285. package/dist/model/units/decimal.js.map +0 -1
  286. package/dist/model/units/index.d.ts +0 -4
  287. package/dist/model/units/index.d.ts.map +0 -1
  288. package/dist/model/units/index.js.map +0 -1
  289. package/dist/model/units/percent.d.ts +0 -12
  290. package/dist/model/units/percent.d.ts.map +0 -1
  291. package/dist/model/units/percent.js +0 -60
  292. package/dist/model/units/percent.js.map +0 -1
  293. package/dist/model/units/time.d.ts +0 -22
  294. package/dist/model/units/time.d.ts.map +0 -1
  295. package/dist/model/units/time.js +0 -91
  296. package/dist/model/units/time.js.map +0 -1
  297. package/dist/model/units/types.d.ts +0 -47
  298. package/dist/model/units/types.d.ts.map +0 -1
  299. package/dist/model/units/types.js.map +0 -1
  300. package/dist/model/units/units.d.ts +0 -40
  301. package/dist/model/units/units.d.ts.map +0 -1
  302. package/dist/model/units/units.js +0 -80
  303. package/dist/model/units/units.js.map +0 -1
  304. package/dist/model/units/utils.d.ts +0 -4
  305. package/dist/model/units/utils.d.ts.map +0 -1
  306. package/dist/model/units/utils.js +0 -32
  307. package/dist/model/units/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Table/Table.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 { useReactTable, getCoreRowModel, ColumnDef, RowSelectionState, OnChangeFn } from '@tanstack/react-table';\nimport { useTheme } from '@mui/material';\nimport { useCallback, useMemo } from 'react';\nimport { VirtualizedTable } from './VirtualizedTable';\nimport { TableCheckbox } from './TableCheckbox';\nimport { TableProps, persesColumnsToTanstackColumns } from './model/table-model';\n\nconst DEFAULT_GET_ROW_ID = (data: unknown, index: number) => {\n return `${index}`;\n};\n\n/**\n * Component used to render tabular data in Perses use cases. This component is\n * **not** intended to be a general use data table for use cases unrelated to Perses.\n *\n * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**\n */\nexport function Table<TableData>({\n data,\n columns,\n density = 'standard',\n checkboxSelection,\n onRowSelectionChange,\n getCheckboxColor,\n getRowId = DEFAULT_GET_ROW_ID,\n rowSelection = {},\n ...otherProps\n}: TableProps<TableData>) {\n const theme = useTheme();\n\n const handleRowSelectionChange: OnChangeFn<RowSelectionState> = (rowSelectionUpdater) => {\n const newRowSelection =\n typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;\n onRowSelectionChange?.(newRowSelection);\n };\n\n const checkboxColumn: ColumnDef<TableData> = useMemo(() => {\n return {\n id: 'checkboxRowSelect',\n size: 32,\n header: ({ table }) => {\n return (\n <TableCheckbox\n checked={table.getIsAllRowsSelected()}\n indeterminate={table.getIsSomeRowsSelected()}\n onChange={table.getToggleAllRowsSelectedHandler()}\n color={theme.palette.text.primary}\n density={density}\n />\n );\n },\n cell: ({ row }) => {\n return (\n <TableCheckbox\n checked={row.getIsSelected()}\n indeterminate={row.getIsSomeSelected()}\n onChange={(e) => {\n row.getToggleSelectedHandler()(e);\n }}\n color={getCheckboxColor?.(row.original)}\n density={density}\n />\n );\n },\n };\n }, [density, getCheckboxColor, theme.palette.text.primary]);\n\n const tableColumns: Array<ColumnDef<TableData>> = useMemo(() => {\n const initTableColumns = persesColumnsToTanstackColumns(columns);\n\n if (checkboxSelection) {\n initTableColumns.unshift(checkboxColumn);\n }\n\n return initTableColumns;\n }, [checkboxColumn, checkboxSelection, columns]);\n\n const table = useReactTable({\n data,\n columns: tableColumns,\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n enableRowSelection: !!checkboxSelection,\n onRowSelectionChange: handleRowSelectionChange,\n state: {\n rowSelection,\n },\n });\n\n const handleRowClick = useCallback(\n (rowId: string) => {\n table.getRow(rowId).toggleSelected();\n },\n [table]\n );\n\n return (\n <VirtualizedTable\n {...otherProps}\n density={density}\n onRowClick={handleRowClick}\n rows={table.getRowModel().rows}\n columns={table.getAllFlatColumns()}\n headers={table.getHeaderGroups()}\n />\n );\n}\n"],"names":["useReactTable","getCoreRowModel","useTheme","useCallback","useMemo","VirtualizedTable","TableCheckbox","persesColumnsToTanstackColumns","DEFAULT_GET_ROW_ID","data","index","Table","columns","density","checkboxSelection","onRowSelectionChange","getCheckboxColor","getRowId","rowSelection","otherProps","theme","handleRowSelectionChange","rowSelectionUpdater","newRowSelection","checkboxColumn","id","size","header","table","checked","getIsAllRowsSelected","indeterminate","getIsSomeRowsSelected","onChange","getToggleAllRowsSelectedHandler","color","palette","text","primary","cell","row","getIsSelected","getIsSomeSelected","e","getToggleSelectedHandler","original","tableColumns","initTableColumns","unshift","enableRowSelection","state","handleRowClick","rowId","getRow","toggleSelected","onRowClick","rows","getRowModel","getAllFlatColumns","headers","getHeaderGroups"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6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AAAC;IAEjD,MAAMgB,KAAK,GAAG5B,aAAa,CAAC;QAC1BS,IAAI;QACJG,OAAO,EAAEkC,YAAY;QACrB7B,QAAQ;QACRhB,eAAe,EAAEA,eAAe,EAAE;QAClCgD,kBAAkB,EAAE,CAAC,CAACnC,iBAAiB;QACvCC,oBAAoB,EAAEM,wBAAwB;QAC9C6B,KAAK,EAAE;YACLhC,YAAY;SACb;KACF,CAAC,AAAC;IAEH,MAAMiC,cAAc,GAAGhD,WAAW,CAChC,CAACiD,KAAa,GAAK;QACjBxB,KAAK,CAACyB,MAAM,CAACD,KAAK,CAAC,CAACE,cAAc,EAAE,CAAC;IACvC,CAAC,EACD;QAAC1B,KAAK;KAAC,CACR,AAAC;IAEF,qBACE,KAACvB,gBAAgB;QACd,GAAGc,UAAU;QACdN,OAAO,EAAEA,OAAO;QAChB0C,UAAU,EAAEJ,cAAc;QAC1BK,IAAI,EAAE5B,KAAK,CAAC6B,WAAW,EAAE,CAACD,IAAI;QAC9B5C,OAAO,EAAEgB,KAAK,CAAC8B,iBAAiB,EAAE;QAClCC,OAAO,EAAE/B,KAAK,CAACgC,eAAe,EAAE;MAChC,CACF;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Table/Table.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 {\n useReactTable,\n getCoreRowModel,\n ColumnDef,\n RowSelectionState,\n OnChangeFn,\n Row,\n Table as TanstackTable,\n SortingState,\n getSortedRowModel,\n} from '@tanstack/react-table';\nimport { useTheme } from '@mui/material';\nimport { useCallback, useMemo } from 'react';\nimport { VirtualizedTable } from './VirtualizedTable';\nimport { TableCheckbox } from './TableCheckbox';\nimport { TableProps, persesColumnsToTanstackColumns } from './model/table-model';\n\nconst DEFAULT_GET_ROW_ID = (data: unknown, index: number) => {\n return `${index}`;\n};\n\n// Setting these defaults one enables them to be consistent across renders instead\n// of being recreated every time, which can be important for perf because react\n// does not do deep equality checking for objects and arrays.\nconst DEFAULT_ROW_SELECTION: NonNullable<TableProps<unknown>['rowSelection']> = {};\nconst DEFAULT_SORTING: NonNullable<TableProps<unknown>['sorting']> = [];\n\n/**\n * Component used to render tabular data in Perses use cases. This component is\n * **not** intended to be a general use data table for use cases unrelated to Perses.\n *\n * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**\n */\nexport function Table<TableData>({\n data,\n columns,\n density = 'standard',\n checkboxSelection,\n onRowSelectionChange,\n onSortingChange,\n getCheckboxColor,\n getRowId = DEFAULT_GET_ROW_ID,\n rowSelection = DEFAULT_ROW_SELECTION,\n sorting = DEFAULT_SORTING,\n rowSelectionVariant = 'standard',\n ...otherProps\n}: TableProps<TableData>) {\n const theme = useTheme();\n\n const handleRowSelectionChange: OnChangeFn<RowSelectionState> = (rowSelectionUpdater) => {\n const newRowSelection =\n typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;\n onRowSelectionChange?.(newRowSelection);\n };\n\n const handleRowSelectionEvent = useCallback(\n (table: TanstackTable<TableData>, row: Row<TableData>, isModified: boolean) => {\n if (rowSelectionVariant === 'standard' || isModified) {\n row.toggleSelected();\n } else {\n // Legend variant (when action not modified with shift/meta key).\n // Note that this behavior needs to be kept in sync with behavior in\n // the Legend component for list-based legends.\n if (row.getIsSelected() && !table.getIsAllRowsSelected()) {\n // Row was already selected. Revert to select all.\n table.toggleAllRowsSelected();\n } else {\n // Focus the selected row.\n onRowSelectionChange?.({\n [row.id]: true,\n });\n }\n }\n },\n [onRowSelectionChange, rowSelectionVariant]\n );\n\n const handleCheckboxChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, table: TanstackTable<TableData>, row: Row<TableData>) => {\n const nativePointerEvent =\n e.nativeEvent && (e.nativeEvent instanceof MouseEvent || e.nativeEvent instanceof KeyboardEvent)\n ? (e.nativeEvent as PointerEvent)\n : undefined;\n const isModifed = !!nativePointerEvent?.metaKey || !!nativePointerEvent?.shiftKey;\n handleRowSelectionEvent(table, row, isModifed);\n },\n [handleRowSelectionEvent]\n );\n\n const handleSortingChange: OnChangeFn<SortingState> = (sortingUpdater) => {\n const newSorting = typeof sortingUpdater === 'function' ? sortingUpdater(sorting) : sortingUpdater;\n onSortingChange?.(newSorting);\n };\n\n const checkboxColumn: ColumnDef<TableData> = useMemo(() => {\n return {\n id: 'checkboxRowSelect',\n size: 28,\n header: ({ table }) => {\n return (\n <TableCheckbox\n checked={table.getIsAllRowsSelected()}\n indeterminate={table.getIsSomeRowsSelected()}\n onChange={table.getToggleAllRowsSelectedHandler()}\n color={theme.palette.text.primary}\n density={density}\n />\n );\n },\n cell: ({ row, table }) => {\n return (\n <TableCheckbox\n checked={row.getIsSelected()}\n indeterminate={row.getIsSomeSelected()}\n onChange={(e) => {\n handleCheckboxChange(e, table, row);\n }}\n color={getCheckboxColor?.(row.original)}\n density={density}\n />\n );\n },\n enableSorting: false,\n };\n }, [theme.palette.text.primary, density, getCheckboxColor, handleCheckboxChange]);\n\n const tableColumns: Array<ColumnDef<TableData>> = useMemo(() => {\n const initTableColumns = persesColumnsToTanstackColumns(columns);\n\n if (checkboxSelection) {\n initTableColumns.unshift(checkboxColumn);\n }\n\n return initTableColumns;\n }, [checkboxColumn, checkboxSelection, columns]);\n\n const table = useReactTable({\n data,\n columns: tableColumns,\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n enableRowSelection: !!checkboxSelection,\n onRowSelectionChange: handleRowSelectionChange,\n onSortingChange: handleSortingChange,\n // For now, defaulting to sort by descending first. We can expose the ability\n // to customize it if/when we have use cases for it.\n sortDescFirst: true,\n state: {\n rowSelection,\n sorting,\n },\n });\n\n const handleRowClick = useCallback(\n (e: React.MouseEvent<HTMLDivElement, MouseEvent>, rowId: string) => {\n const row = table.getRow(rowId);\n const isModifiedClick = e.metaKey || e.shiftKey;\n handleRowSelectionEvent(table, row, isModifiedClick);\n },\n [handleRowSelectionEvent, table]\n );\n\n return (\n <VirtualizedTable\n {...otherProps}\n density={density}\n onRowClick={handleRowClick}\n rows={table.getRowModel().rows}\n columns={table.getAllFlatColumns()}\n headers={table.getHeaderGroups()}\n />\n );\n}\n"],"names":["useReactTable","getCoreRowModel","getSortedRowModel","useTheme","useCallback","useMemo","VirtualizedTable","TableCheckbox","persesColumnsToTanstackColumns","DEFAULT_GET_ROW_ID","data","index","DEFAULT_ROW_SELECTION","DEFAULT_SORTING","Table","columns","density","checkboxSelection","onRowSelectionChange","onSortingChange","getCheckboxColor","getRowId","rowSelection","sorting","rowSelectionVariant","otherProps","theme","handleRowSelectionChange","rowSelectionUpdater","newRowSelection","handleRowSelectionEvent","table","row","isModified","toggleSelected","getIsSelected","getIsAllRowsSelected","toggleAllRowsSelected","id","handleCheckboxChange","e","nativePointerEvent","nativeEvent","MouseEvent","KeyboardEvent","undefined","isModifed","metaKey","shiftKey","handleSortingChange","sortingUpdater","newSorting","checkboxColumn","size","header","checked","indeterminate","getIsSomeRowsSelected","onChange","getToggleAllRowsSelectedHandler","color","palette","text","primary","cell","getIsSomeSelected","original","enableSorting","tableColumns","initTableColumns","unshift","enableRowSelection","sortDescFirst","state","handleRowClick","rowId","getRow","isModifiedClick","onRowClick","rows","getRowModel","getAllFlatColumns","headers","getHeaderGroups"],"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,SACEA,aA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AC,CAAC;IACvD,CAAC,EACD;QAAC/C,uBAAuB;QAAEC,KAAK;KAAC,CACjC,AAAC;IAEF,qBACE,KAACzB,gBAAgB;QACd,GAAGmB,UAAU;QACdT,OAAO,EAAEA,OAAO;QAChB8D,UAAU,EAAEJ,cAAc;QAC1BK,IAAI,EAAEhD,KAAK,CAACiD,WAAW,EAAE,CAACD,IAAI;QAC9BhE,OAAO,EAAEgB,KAAK,CAACkD,iBAAiB,EAAE;QAClCC,OAAO,EAAEnD,KAAK,CAACoD,eAAe,EAAE;MAChC,CACF;AACJ,CAAC"}
@@ -1,8 +1,21 @@
1
1
  /// <reference types="react" />
2
2
  import { TableCellProps as MuiTableCellProps } from '@mui/material';
3
- import { TableDensity } from './model/table-model';
4
- export interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex'> {
3
+ import { TableCellAlignment, TableDensity } from './model/table-model';
4
+ export interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex' | 'align'> {
5
5
  density: TableDensity;
6
+ isLastColumn: boolean;
7
+ isFirstColumn: boolean;
8
+ align?: TableCellAlignment;
9
+ /**
10
+ * Additional information to be displayed when hovering over the cell. This
11
+ * may be the full cell value (e.g. to enable the user to see the full value
12
+ * if it is ellipsized to fit into the space) or some other descriptive text
13
+ * that is useful for the user.
14
+ *
15
+ * The hover behavior is currently managed with the `title` attribute, but this
16
+ * may be changed to a tooltip in the future.
17
+ */
18
+ description?: string;
6
19
  /**
7
20
  * How the cell should behave related to focus.
8
21
  * - `trigger-focus`: the cell should be auto-focused when it renders.
@@ -14,5 +27,5 @@ export interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex'> {
14
27
  focusState?: 'trigger-focus' | 'focus-next' | 'none';
15
28
  onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;
16
29
  }
17
- export declare function TableCell({ children, density, variant, width, focusState, onFocusTrigger, ...otherProps }: TableCellProps): JSX.Element;
30
+ export declare function TableCell({ children, density, variant, width, focusState, onFocusTrigger, isFirstColumn, isLastColumn, description, ...otherProps }: TableCellProps): JSX.Element;
18
31
  //# sourceMappingURL=TableCell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../src/Table/TableCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAqC,cAAc,IAAI,iBAAiB,EAAiB,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAmBvE,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACzE,OAAO,EAAE,YAAY,CAAC;IAEtB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,MAAM,CAAC;IACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;CAClH;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,KAAK,EACL,UAAmB,EACnB,cAAc,EACd,GAAG,UAAU,EACd,EAAE,cAAc,eAqEhB"}
1
+ {"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../src/Table/TableCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAqC,cAAc,IAAI,iBAAiB,EAAiB,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAmB3F,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC;IACnF,OAAO,EAAE,YAAY,CAAC;IAGtB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IAEvB,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAE3B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,MAAM,CAAC;IACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;CAClH;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,KAAK,EACL,UAAmB,EACnB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,GAAG,UAAU,EACd,EAAE,cAAc,eA2EhB"}
@@ -19,7 +19,7 @@ const StyledMuiTableCell = styled(MuiTableCell)(({ theme })=>({
19
19
  backgroundColor: 'inherit',
20
20
  '&.MuiTableCell-head': {
21
21
  // Important to avoid scrolling behind the header showing through.
22
- backgroundColor: theme.palette.background.paper
22
+ backgroundColor: theme.palette.background.default
23
23
  },
24
24
  '&:focus-visible': {
25
25
  outline: `solid 1px ${theme.palette.primary.main}`,
@@ -29,7 +29,7 @@ const StyledMuiTableCell = styled(MuiTableCell)(({ theme })=>({
29
29
  borderRadius: 0
30
30
  }
31
31
  }));
32
- export function TableCell({ children , density , variant , width , focusState ='none' , onFocusTrigger , ...otherProps }) {
32
+ export function TableCell({ children , density , variant , width , focusState ='none' , onFocusTrigger , isFirstColumn , isLastColumn , description , ...otherProps }) {
33
33
  const theme = useTheme();
34
34
  const elRef = useRef();
35
35
  const isHeader = variant === 'head';
@@ -43,7 +43,7 @@ export function TableCell({ children , density , variant , width , focusState ='
43
43
  const handleFocus = (e)=>{
44
44
  var ref;
45
45
  // From https://zellwk.com/blog/keyboard-focusable-elements/
46
- const nestedFocusTarget = (ref = e.currentTarget) === null || ref === void 0 ? void 0 : ref.querySelector('a[href], button, input, textarea, select, details');
46
+ const nestedFocusTarget = (ref = e.currentTarget) === null || ref === void 0 ? void 0 : ref.querySelector('a[href], button, input, textarea, select, details,[role="button"]');
47
47
  if (nestedFocusTarget) {
48
48
  // If the cell has a focusable child, focus it instead. Mostly used for
49
49
  // checkbox cells, but could have other uses.
@@ -75,14 +75,22 @@ export function TableCell({ children , density , variant , width , focusState ='
75
75
  ref: elRef,
76
76
  children: /*#__PURE__*/ _jsx(Box, {
77
77
  sx: {
78
- ...getTableCellLayout(theme, density),
78
+ ...getTableCellLayout(theme, density, {
79
+ isLastColumn,
80
+ isFirstColumn
81
+ }),
79
82
  position: 'relative',
80
83
  // Text truncation. Currently enforced on all cells. We may control
81
84
  // this with a prop on column config in the future.
82
85
  whiteSpace: 'nowrap',
83
86
  overflow: 'hidden',
84
- textOverflow: 'ellipsis'
87
+ textOverflow: 'ellipsis',
88
+ // Need to inherit from the MUI cell because this manages some ordering
89
+ // that the `TableSortLabel` uses to determine the location of the icon
90
+ // in headers.
91
+ flexDirection: 'inherit'
85
92
  },
93
+ title: description,
86
94
  children: children
87
95
  })
88
96
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Table/TableCell.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 { TableCell as MuiTableCell, styled, TableCellProps as MuiTableCellProps, Box, useTheme } from '@mui/material';\nimport { useEffect, useRef } from 'react';\nimport { TableDensity, getTableCellLayout } from './model/table-model';\n\nconst StyledMuiTableCell = styled(MuiTableCell)(({ theme }) => ({\n padding: 0,\n backgroundColor: 'inherit',\n\n '&.MuiTableCell-head': {\n // Important to avoid scrolling behind the header showing through.\n backgroundColor: theme.palette.background.paper,\n },\n '&:focus-visible': {\n outline: `solid 1px ${theme.palette.primary.main}`,\n // Move inward a little to avoid getting cut off when focusing on items\n // at the edge of the table.\n outlineOffset: '-1px',\n borderRadius: 0,\n },\n}));\n\nexport interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex'> {\n density: TableDensity;\n\n /**\n * How the cell should behave related to focus.\n * - `trigger-focus`: the cell should be auto-focused when it renders.\n * - `focus-next`: the cell should have tabindex=\"0\", so that it will be\n * focused the next time someone tabs with a keyboard.\n * - `none`: the cell should have tabindex=\"-1\", so it is not focused by\n * keyboard interactions at this time.\n */\n focusState?: 'trigger-focus' | 'focus-next' | 'none';\n onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;\n}\n\nexport function TableCell({\n children,\n density,\n variant,\n width,\n focusState = 'none',\n onFocusTrigger,\n ...otherProps\n}: TableCellProps) {\n const theme = useTheme();\n\n const elRef = useRef<HTMLTableCellElement>();\n\n const isHeader = variant === 'head';\n\n useEffect(() => {\n if (focusState === 'trigger-focus' && elRef.current) {\n elRef.current.focus();\n }\n }, [focusState]);\n\n const handleFocus: React.FocusEventHandler<HTMLTableCellElement> = (e) => {\n // From https://zellwk.com/blog/keyboard-focusable-elements/\n const nestedFocusTarget = e.currentTarget?.querySelector<HTMLElement>(\n 'a[href], button, input, textarea, select, details'\n );\n if (nestedFocusTarget) {\n // If the cell has a focusable child, focus it instead. Mostly used for\n // checkbox cells, but could have other uses.\n nestedFocusTarget.focus();\n }\n };\n\n const handleInteractionFocusTrigger: TableCellProps['onFocusTrigger'] = (e) => {\n // We use `onClick` and `onKeyUp` events instead of `onFocus` because of\n // some ordering issues with when the browser calls events and how this\n // plays with the triggering of focus with keyboard interactions.\n // These report that a focus event happened, so we can adjust the current\n // tabindex and focuses to the right cell.\n onFocusTrigger?.(e);\n };\n\n return (\n <StyledMuiTableCell\n {...otherProps}\n // Modify the tab index based on the currently focused cell. It's important\n // to avoid having tabindex 0 on everything because it essentially traps\n // a keyboard user in the table until they hit \"tab\" for every single\n // cell.\n tabIndex={focusState !== 'none' ? 0 : -1}\n onFocus={handleFocus}\n onClick={handleInteractionFocusTrigger}\n onKeyUp={handleInteractionFocusTrigger}\n sx={{\n width: width,\n borderBottom: isHeader\n ? (theme) => `solid 1px ${theme.palette.grey[100]}`\n : `solid 1px ${theme.palette.grey[50]}`,\n }}\n ref={elRef}\n >\n <Box\n sx={{\n ...getTableCellLayout(theme, density),\n position: 'relative',\n\n // Text truncation. Currently enforced on all cells. We may control\n // this with a prop on column config in the future.\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {children}\n </Box>\n </StyledMuiTableCell>\n );\n}\n"],"names":["TableCell","MuiTableCell","styled","Box","useTheme","useEffect","useRef","getTableCellLayout","StyledMuiTableCell","theme","padding","backgroundColor","palette","background","paper","outline","primary","main","outlineOffset","borderRadius","children","density","variant","width","focusState","onFocusTrigger","otherProps","elRef","isHeader","current","focus","handleFocus","e","nestedFocusTarget","currentTarget","querySelector","handleInteractionFocusTrigger","tabIndex","onFocus","onClick","onKeyUp","sx","borderBottom","grey","ref","position","whiteSpace","overflow","textOverflow"],"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,SAAS,IAAIC,YAAY,EAAEC,MAAM,EAAuCC,GAAG,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AACtH,SAASC,SAAS,EAAEC,MAAM,QAAQ,OAAO,CAAC;AAC1C,SAAuBC,kBAAkB,QAAQ,qBAAqB,CAAC;AAEvE,MAAMC,kBAAkB,GAAGN,MAAM,CAACD,YAAY,CAAC,CAAC,CAAC,EAAEQ,KAAK,CAAA,EAAE,GAAM,CAAA;QAC9DC,OAA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AE,CAAC;QAC5B,CAAC;IACH,CAAC,AAAC;IAEF,MAAMM,6BAA6B,GAAqC,CAACJ,CAAC,GAAK;QAC7E,wEAAwE;QACxE,uEAAuE;QACvE,iEAAiE;QACjE,yEAAyE;QACzE,0CAA0C;QAC1CP,cAAc,aAAdA,cAAc,WAAK,GAAnBA,KAAAA,CAAmB,GAAnBA,cAAc,CAAGO,CAAC,CAAC,CAAC;IACtB,CAAC,AAAC;IAEF,qBACE,KAACxB,kBAAkB;QAChB,GAAGkB,UAAU;QACd,2EAA2E;QAC3E,wEAAwE;QACxE,qEAAqE;QACrE,QAAQ;QACRW,QAAQ,EAAEb,UAAU,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;QACxCc,OAAO,EAAEP,WAAW;QACpBQ,OAAO,EAAEH,6BAA6B;QACtCI,OAAO,EAAEJ,6BAA6B;QACtCK,EAAE,EAAE;YACFlB,KAAK,EAAEA,KAAK;YACZmB,YAAY,EAAEd,QAAQ,GAClB,CAACnB,KAAK,GAAK,CAAC,UAAU,EAAEA,KAAK,CAACG,OAAO,CAAC+B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GACjD,CAAC,UAAU,EAAElC,KAAK,CAACG,OAAO,CAAC+B,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;SAC1C;QACDC,GAAG,EAAEjB,KAAK;kBAEV,cAAA,KAACxB,GAAG;YACFsC,EAAE,EAAE;gBACF,GAAGlC,kBAAkB,CAACE,KAAK,EAAEY,OAAO,CAAC;gBACrCwB,QAAQ,EAAE,UAAU;gBAEpB,mEAAmE;gBACnE,mDAAmD;gBACnDC,UAAU,EAAE,QAAQ;gBACpBC,QAAQ,EAAE,QAAQ;gBAClBC,YAAY,EAAE,UAAU;aACzB;sBAEA5B,QAAQ;UACL;MACa,CACrB;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/Table/TableCell.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 { TableCell as MuiTableCell, styled, TableCellProps as MuiTableCellProps, Box, useTheme } from '@mui/material';\nimport { useEffect, useRef } from 'react';\nimport { TableCellAlignment, TableDensity, getTableCellLayout } from './model/table-model';\n\nconst StyledMuiTableCell = styled(MuiTableCell)(({ theme }) => ({\n padding: 0,\n backgroundColor: 'inherit',\n\n '&.MuiTableCell-head': {\n // Important to avoid scrolling behind the header showing through.\n backgroundColor: theme.palette.background.default,\n },\n '&:focus-visible': {\n outline: `solid 1px ${theme.palette.primary.main}`,\n // Move inward a little to avoid getting cut off when focusing on items\n // at the edge of the table.\n outlineOffset: '-1px',\n borderRadius: 0,\n },\n}));\n\nexport interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex' | 'align'> {\n density: TableDensity;\n\n // These values are used to adjust the spacing for the first/last columns.\n isLastColumn: boolean;\n isFirstColumn: boolean;\n\n align?: TableCellAlignment;\n\n /**\n * Additional information to be displayed when hovering over the cell. This\n * may be the full cell value (e.g. to enable the user to see the full value\n * if it is ellipsized to fit into the space) or some other descriptive text\n * that is useful for the user.\n *\n * The hover behavior is currently managed with the `title` attribute, but this\n * may be changed to a tooltip in the future.\n */\n description?: string;\n\n /**\n * How the cell should behave related to focus.\n * - `trigger-focus`: the cell should be auto-focused when it renders.\n * - `focus-next`: the cell should have tabindex=\"0\", so that it will be\n * focused the next time someone tabs with a keyboard.\n * - `none`: the cell should have tabindex=\"-1\", so it is not focused by\n * keyboard interactions at this time.\n */\n focusState?: 'trigger-focus' | 'focus-next' | 'none';\n onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;\n}\n\nexport function TableCell({\n children,\n density,\n variant,\n width,\n focusState = 'none',\n onFocusTrigger,\n isFirstColumn,\n isLastColumn,\n description,\n ...otherProps\n}: TableCellProps) {\n const theme = useTheme();\n\n const elRef = useRef<HTMLTableCellElement>();\n\n const isHeader = variant === 'head';\n\n useEffect(() => {\n if (focusState === 'trigger-focus' && elRef.current) {\n elRef.current.focus();\n }\n }, [focusState]);\n\n const handleFocus: React.FocusEventHandler<HTMLTableCellElement> = (e) => {\n // From https://zellwk.com/blog/keyboard-focusable-elements/\n const nestedFocusTarget = e.currentTarget?.querySelector<HTMLElement>(\n 'a[href], button, input, textarea, select, details,[role=\"button\"]'\n );\n if (nestedFocusTarget) {\n // If the cell has a focusable child, focus it instead. Mostly used for\n // checkbox cells, but could have other uses.\n nestedFocusTarget.focus();\n }\n };\n\n const handleInteractionFocusTrigger: TableCellProps['onFocusTrigger'] = (e) => {\n // We use `onClick` and `onKeyUp` events instead of `onFocus` because of\n // some ordering issues with when the browser calls events and how this\n // plays with the triggering of focus with keyboard interactions.\n // These report that a focus event happened, so we can adjust the current\n // tabindex and focuses to the right cell.\n onFocusTrigger?.(e);\n };\n\n return (\n <StyledMuiTableCell\n {...otherProps}\n // Modify the tab index based on the currently focused cell. It's important\n // to avoid having tabindex 0 on everything because it essentially traps\n // a keyboard user in the table until they hit \"tab\" for every single\n // cell.\n tabIndex={focusState !== 'none' ? 0 : -1}\n onFocus={handleFocus}\n onClick={handleInteractionFocusTrigger}\n onKeyUp={handleInteractionFocusTrigger}\n sx={{\n width: width,\n borderBottom: isHeader\n ? (theme) => `solid 1px ${theme.palette.grey[100]}`\n : `solid 1px ${theme.palette.grey[50]}`,\n }}\n ref={elRef}\n >\n <Box\n sx={{\n ...getTableCellLayout(theme, density, { isLastColumn, isFirstColumn }),\n position: 'relative',\n\n // Text truncation. Currently enforced on all cells. We may control\n // this with a prop on column config in the future.\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n\n // Need to inherit from the MUI cell because this manages some ordering\n // that the `TableSortLabel` uses to determine the location of the icon\n // in headers.\n flexDirection: 'inherit',\n }}\n title={description}\n >\n {children}\n </Box>\n </StyledMuiTableCell>\n );\n}\n"],"names":["TableCell","MuiTableCell","styled","Box","useTheme","useEffect","useRef","getTableCellLayout","StyledMuiTableCell","theme","padding","backgroundColor","palette","background","default","outline","primary","main","outlineOffset","borderRadius","children","density","variant","width","focusState","onFocusTrigger","isFirstColumn","isLastColumn","description","otherProps","elRef","isHeader","current","focus","handleFocus","e","nestedFocusTarget","currentTarget","querySelector","handleInteractionFocusTrigger","tabIndex","onFocus","onClick","onKeyUp","sx","borderBottom","grey","ref","position","whiteSpace","overflow","textOverflow","flexDirection","title"],"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,SAAS,IAAIC,YAAY,EAAEC,MAAM,EAAuCC,GAAG,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AACtH,SAASC,SAAS,EAAEC,MAAM,QAAQ,OAAO,CAAC;AAC1C,SAA2CC,kBAAkB,QAAQ,qBAAqB,CAAC;AAE3F,MAAMC,kBAAkB,GAAGN,MAAM,CAACD,YAAY,CAAC,CAAC,CAAC,EAAEQ,KAAK,CAAA,EAAE,GAAM,CAAA;QAC9DC,OAAO,EAAE,CAAC;QACVC,eAAe,EAAE,SAAS;QAE1B,qBAAqB,EAAE;YACrB,kEAAkE;YAClEA,eAAe,EAAEF,KAAK,CAACG,OAAO,CAACC,UAAU,CAACC,OAAO;SAClD;QACD,iBAAiB,EAAE;YACjBC,OAAO,EAAE,CAAC,UAAU,EAAEN,KAAK,CAACG,OAAO,CAACI,OAAO,CAACC,IAAI,CAAC,CAAC;YAClD,uEAAuE;YACvE,4BA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,cAAc,CAAGU,CAAC,CAAC,CAAC;IACtB,CAAC,AAAC;IAEF,qBACE,KAAC3B,kBAAkB;QAChB,GAAGqB,UAAU;QACd,2EAA2E;QAC3E,wEAAwE;QACxE,qEAAqE;QACrE,QAAQ;QACRW,QAAQ,EAAEhB,UAAU,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;QACxCiB,OAAO,EAAEP,WAAW;QACpBQ,OAAO,EAAEH,6BAA6B;QACtCI,OAAO,EAAEJ,6BAA6B;QACtCK,EAAE,EAAE;YACFrB,KAAK,EAAEA,KAAK;YACZsB,YAAY,EAAEd,QAAQ,GAClB,CAACtB,KAAK,GAAK,CAAC,UAAU,EAAEA,KAAK,CAACG,OAAO,CAACkC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GACjD,CAAC,UAAU,EAAErC,KAAK,CAACG,OAAO,CAACkC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;SAC1C;QACDC,GAAG,EAAEjB,KAAK;kBAEV,cAAA,KAAC3B,GAAG;YACFyC,EAAE,EAAE;gBACF,GAAGrC,kBAAkB,CAACE,KAAK,EAAEY,OAAO,EAAE;oBAAEM,YAAY;oBAAED,aAAa;iBAAE,CAAC;gBACtEsB,QAAQ,EAAE,UAAU;gBAEpB,mEAAmE;gBACnE,mDAAmD;gBACnDC,UAAU,EAAE,QAAQ;gBACpBC,QAAQ,EAAE,QAAQ;gBAClBC,YAAY,EAAE,UAAU;gBAExB,uEAAuE;gBACvE,uEAAuE;gBACvE,cAAc;gBACdC,aAAa,EAAE,SAAS;aACzB;YACDC,KAAK,EAAEzB,WAAW;sBAEjBR,QAAQ;UACL;MACa,CACrB;AACJ,CAAC"}
@@ -40,7 +40,7 @@ export function TableCheckbox({ color , density , ...otherProps }) {
40
40
  background: color ? alpha(color, 0.5) : undefined
41
41
  },
42
42
  '& .MuiSvgIcon-root': {
43
- fontSize: isCompact ? 14 : 16
43
+ fontSize: isCompact ? 16 : 18
44
44
  }
45
45
  }
46
46
  });
@@ -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","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"}
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 ? 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;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;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A,OAAO,EAA2B,aAAa,IAAI,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,UAAU,aAAc,SAAQ,gBAAgB,CAAC,KAAK,CAAC;IACrD,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,QAAQ,iqJAanB,CAAC"}
1
+ {"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../src/Table/TableRow.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA2B,aAAa,IAAI,gBAAgB,EAAS,MAAM,eAAe,CAAC;AAElG,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,UAAU,aAAc,SAAQ,gBAAgB,CAAC,KAAK,CAAC;IACrD,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,QAAQ,iqJAanB,CAAC"}
@@ -11,16 +11,16 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { TableRow as MuiTableRow } from '@mui/material';
14
+ import { TableRow as MuiTableRow, alpha } from '@mui/material';
15
15
  import { forwardRef } from 'react';
16
16
  export const TableRow = /*#__PURE__*/ forwardRef(function TableRow(props, ref) {
17
17
  return /*#__PURE__*/ _jsx(MuiTableRow, {
18
18
  ...props,
19
19
  ref: ref,
20
20
  sx: {
21
- backgroundColor: (theme)=>theme.palette.background.paper,
21
+ backgroundColor: (theme)=>theme.palette.background.default,
22
22
  '&:hover': {
23
- backgroundColor: (theme)=>theme.palette.primary.light
23
+ backgroundColor: (theme)=>alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity)
24
24
  }
25
25
  }
26
26
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Table/TableRow.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 { TableRow as MuiTableRow, TableRowProps as MuiTableRowProps } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { TableDensity } from './model/table-model';\n\ninterface TableRowProps extends MuiTableRowProps<'div'> {\n density: TableDensity;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(props, ref) {\n return (\n <MuiTableRow\n {...props}\n ref={ref}\n sx={{\n backgroundColor: (theme) => theme.palette.background.paper,\n '&:hover': {\n backgroundColor: (theme) => theme.palette.primary.light,\n },\n }}\n />\n );\n});\n"],"names":["TableRow","MuiTableRow","forwardRef","props","ref","sx","backgroundColor","theme","palette","background","paper","primary","light"],"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,IAAIC,WAAW,QAA2C,eAAe,CAAC;AAC3F,SAASC,UAAU,QAAQ,OAAO,CAAC;AAOnC,OAAO,MAAMF,QAAQ,iBAAGE,UAAU,CAAqC,SAASF,QAAQ,CAACG,KAAK,EAAEC,GAAG,EAAE;IACnG,qBACE,KAACH,WAAW;QACT,GAAGE,KAAK;QACTC,GAAG,EAAEA,GAAG;QACRC,EAAE,EAAE;YACFC,eAAe,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACC,UAAU,CAACC,KAAK;YAC1D,SAAS,EAAE;gBACTJ,eAAe,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACG,OAAO,CAACC,KAAK;aACxD;SACF;MACD,CACF;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/Table/TableRow.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 { TableRow as MuiTableRow, TableRowProps as MuiTableRowProps, alpha } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { TableDensity } from './model/table-model';\n\ninterface TableRowProps extends MuiTableRowProps<'div'> {\n density: TableDensity;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(props, ref) {\n return (\n <MuiTableRow\n {...props}\n ref={ref}\n sx={{\n backgroundColor: (theme) => theme.palette.background.default,\n '&:hover': {\n backgroundColor: (theme) => alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity),\n },\n }}\n />\n );\n});\n"],"names":["TableRow","MuiTableRow","alpha","forwardRef","props","ref","sx","backgroundColor","theme","palette","background","default","primary","main","action","hoverOpacity"],"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,IAAIC,WAAW,EAAqCC,KAAK,QAAQ,eAAe,CAAC;AAClG,SAASC,UAAU,QAAQ,OAAO,CAAC;AAOnC,OAAO,MAAMH,QAAQ,iBAAGG,UAAU,CAAqC,SAASH,QAAQ,CAACI,KAAK,EAAEC,GAAG,EAAE;IACnG,qBACE,KAACJ,WAAW;QACT,GAAGG,KAAK;QACTC,GAAG,EAAEA,GAAG;QACRC,EAAE,EAAE;YACFC,eAAe,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACC,UAAU,CAACC,OAAO;YAC5D,SAAS,EAAE;gBACTJ,eAAe,EAAE,CAACC,KAAK,GAAKN,KAAK,CAACM,KAAK,CAACC,OAAO,CAACG,OAAO,CAACC,IAAI,EAAEL,KAAK,CAACC,OAAO,CAACK,MAAM,CAACC,YAAY,CAAC;aACjG;SACF;MACD,CACF;AACJ,CAAC,CAAC,CAAC"}
@@ -1,11 +1,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,EAA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CAAC,SAAS,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3C,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;CACxC,CAAC;AAKJ,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,EAC1C,KAAK,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,aAAa,EACb,IAAI,EACJ,OAAO,EACP,OAAO,GACR,EAAE,qBAAqB,CAAC,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
  ]);
@@ -102,18 +115,28 @@ export function VirtualizedTable({ width , height , density , onRowClick , rows
102
115
  children: headers.map((headerGroup)=>{
103
116
  return /*#__PURE__*/ _jsx(TableRow, {
104
117
  density: density,
105
- children: headerGroup.headers.map((header, i)=>{
118
+ children: headerGroup.headers.map((header, i, headers)=>{
119
+ var ref, ref1;
106
120
  const column = header.column;
107
121
  const position = {
108
122
  row: 0,
109
123
  column: i
110
124
  };
111
- 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,
112
131
  width: column.getSize() || 'auto',
132
+ align: (ref = column.columnDef.meta) === null || ref === void 0 ? void 0 : ref.align,
113
133
  variant: "head",
114
134
  density: density,
135
+ description: (ref1 = column.columnDef.meta) === null || ref1 === void 0 ? void 0 : ref1.headerDescription,
115
136
  focusState: getFocusState(position),
116
137
  onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
138
+ isFirstColumn: i === 0,
139
+ isLastColumn: i === headers.length - 1,
117
140
  children: flexRender(column.columnDef.header, header.getContext())
118
141
  }, header.id);
119
142
  })
@@ -127,20 +150,38 @@ export function VirtualizedTable({ width , height , density , onRowClick , rows
127
150
  return null;
128
151
  }
129
152
  return /*#__PURE__*/ _jsx(_Fragment, {
130
- children: row.getVisibleCells().map((cell, i)=>{
153
+ children: row.getVisibleCells().map((cell, i, cells)=>{
154
+ var ref, ref1;
131
155
  const position = {
132
156
  // Add 1 to the row index because the header is row 0
133
157
  row: index + 1,
134
158
  column: i
135
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
+ }
136
175
  return /*#__PURE__*/ _jsx(TableCell, {
137
- sx: {
138
- width: cell.column.getSize() || 'auto'
139
- },
176
+ width: cell.column.getSize() || 'auto',
177
+ align: (ref1 = cell.column.columnDef.meta) === null || ref1 === void 0 ? void 0 : ref1.align,
140
178
  density: density,
141
179
  focusState: getFocusState(position),
142
180
  onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
143
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
181
+ isFirstColumn: i === 0,
182
+ isLastColumn: i === cells.length - 1,
183
+ description: description,
184
+ children: cellContent
144
185
  }, cell.id);
145
186
  })
146
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) => {\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 variant=\"head\"\n density={density}\n focusState={getFocusState(position)}\n onFocusTrigger={() => keyboardNav.onCellFocus(position)}\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) => {\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 sx={{ width: cell.column.getSize() || 'auto' }}\n density={density}\n focusState={getFocusState(position)}\n onFocusTrigger={() => keyboardNav.onCellFocus(position)}\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","variant","focusState","onFocusTrigger","onCellFocus","columnDef","getContext","itemContent","getVisibleCells","cell"],"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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,EAAE7B,aAAa,CAAC0B,QAAQ,CAAC;4BACnCI,cAAc,EAAE,IAAMnC,WAAW,CAACoC,WAAW,CAACL,QAAQ,CAAC;sCAEtD1D,UAAU,CAACoE,IAAI,CAAChC,MAAM,CAAC4B,SAAS,CAACI,IAAI,EAAEA,IAAI,CAACH,UAAU,EAAE,CAAC;2BANrDG,IAAI,CAACrB,EAAE,CAOF,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,oEA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