@perses-dev/components 0.56.0-beta.0 → 0.56.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ import { c as _c } from "react-compiler-runtime";
14
14
  // limitations under the License.
15
15
  import { Box, TablePagination, TableRow as MuiTableRow } from "@mui/material";
16
16
  import { flexRender } from "@tanstack/react-table";
17
- import { useRef } from "react";
17
+ import { forwardRef, useRef } from "react";
18
18
  import { TableVirtuoso } from "react-virtuoso";
19
19
  import { useVirtualizedTableKeyboardNav } from "./hooks/useVirtualizedTableKeyboardNav.js";
20
20
  import { InnerTable } from "./InnerTable.js";
@@ -26,11 +26,143 @@ import { TableHeaderCell } from "./TableHeaderCell.js";
26
26
  import { TableRow } from "./TableRow.js";
27
27
  import { TableToolbar } from "./TableToolbar.js";
28
28
  import { VirtualizedTableContainer } from "./VirtualizedTableContainer.js";
29
+ // Defined outside VirtualizedTable so the object reference is stable and
30
+ // TableVirtuoso never remounts its internal components due to a changed prop.
31
+ // Props that vary per-render are passed via the `context` prop instead.
32
+ const VirtuosoTableComponents = {
33
+ Scroller: /*#__PURE__*/ forwardRef((t0, ref)=>{
34
+ const $ = _c(5);
35
+ let props;
36
+ if ($[0] !== t0) {
37
+ const { context: _, ...t1 } = t0;
38
+ props = t1;
39
+ $[0] = t0;
40
+ $[1] = props;
41
+ } else {
42
+ props = $[1];
43
+ }
44
+ let t1;
45
+ if ($[2] !== props || $[3] !== ref) {
46
+ t1 = /*#__PURE__*/ _jsx(VirtualizedTableContainer, {
47
+ ...props,
48
+ ref: ref
49
+ });
50
+ $[2] = props;
51
+ $[3] = ref;
52
+ $[4] = t1;
53
+ } else {
54
+ t1 = $[4];
55
+ }
56
+ return t1;
57
+ }),
58
+ Table: ({ context, ...props })=>/*#__PURE__*/ _jsx(InnerTable, {
59
+ ...props,
60
+ width: context.width,
61
+ density: context.density,
62
+ onKeyDown: context.onTableKeyDown,
63
+ onBlur: context.onTableBlur
64
+ }),
65
+ TableHead: /*#__PURE__*/ forwardRef((t0, ref)=>{
66
+ const $ = _c(5);
67
+ let props;
68
+ if ($[0] !== t0) {
69
+ const { context: _, ...t1 } = t0;
70
+ props = t1;
71
+ $[0] = t0;
72
+ $[1] = props;
73
+ } else {
74
+ props = $[1];
75
+ }
76
+ let t1;
77
+ if ($[2] !== props || $[3] !== ref) {
78
+ t1 = /*#__PURE__*/ _jsx(TableHead, {
79
+ ...props,
80
+ ref: ref
81
+ });
82
+ $[2] = props;
83
+ $[3] = ref;
84
+ $[4] = t1;
85
+ } else {
86
+ t1 = $[4];
87
+ }
88
+ return t1;
89
+ }),
90
+ TableFoot: /*#__PURE__*/ forwardRef((t0, ref)=>{
91
+ const $ = _c(5);
92
+ let props;
93
+ if ($[0] !== t0) {
94
+ const { context: _, ...t1 } = t0;
95
+ props = t1;
96
+ $[0] = t0;
97
+ $[1] = props;
98
+ } else {
99
+ props = $[1];
100
+ }
101
+ let t1;
102
+ if ($[2] !== props || $[3] !== ref) {
103
+ t1 = /*#__PURE__*/ _jsx(TableFoot, {
104
+ ...props,
105
+ ref: ref
106
+ });
107
+ $[2] = props;
108
+ $[3] = ref;
109
+ $[4] = t1;
110
+ } else {
111
+ t1 = $[4];
112
+ }
113
+ return t1;
114
+ }),
115
+ TableRow: ({ item, context, ...props })=>{
116
+ if (!item) {
117
+ return null;
118
+ }
119
+ const rowEventOpts = {
120
+ id: item.id,
121
+ index: item.index
122
+ };
123
+ return /*#__PURE__*/ _jsx(TableRow, {
124
+ ...props,
125
+ onClick: (e)=>context.onRowClick(e, item),
126
+ density: context.density,
127
+ onMouseOver: (e)=>{
128
+ context.onRowMouseOver?.(e, rowEventOpts);
129
+ },
130
+ onMouseOut: (e)=>{
131
+ context.onRowMouseOut?.(e, rowEventOpts);
132
+ }
133
+ });
134
+ },
135
+ TableBody: /*#__PURE__*/ forwardRef((t0, ref)=>{
136
+ const $ = _c(5);
137
+ let props;
138
+ if ($[0] !== t0) {
139
+ const { context: _, ...t1 } = t0;
140
+ props = t1;
141
+ $[0] = t0;
142
+ $[1] = props;
143
+ } else {
144
+ props = $[1];
145
+ }
146
+ let t1;
147
+ if ($[2] !== props || $[3] !== ref) {
148
+ t1 = /*#__PURE__*/ _jsx(TableBody, {
149
+ ...props,
150
+ ref: ref
151
+ });
152
+ $[2] = props;
153
+ $[3] = ref;
154
+ $[4] = t1;
155
+ } else {
156
+ t1 = $[4];
157
+ }
158
+ return t1;
159
+ })
160
+ };
29
161
  // Separating out the virtualized table because we may want a paginated table
30
162
  // in the future that does not need virtualization, and we'd likely lay them
31
163
  // out differently.
32
164
  export function VirtualizedTable(t0) {
33
- const $ = _c(71);
165
+ const $ = _c(65);
34
166
  const { width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, table, cellConfigs, pagination, onPaginationChange, toolbarConfig } = t0;
35
167
  let t1;
36
168
  if ($[0] !== table) {
@@ -104,76 +236,31 @@ export function VirtualizedTable(t0) {
104
236
  }
105
237
  const getFocusState = t7;
106
238
  let t8;
107
- if ($[12] !== density || $[13] !== keyboardNav.onTableBlur || $[14] !== keyboardNav.onTableKeyDown || $[15] !== width) {
108
- t8 = (props)=>/*#__PURE__*/ _jsx(InnerTable, {
109
- ...props,
110
- width: width,
111
- density: density,
112
- onKeyDown: keyboardNav.onTableKeyDown,
113
- onBlur: keyboardNav.onTableBlur
114
- });
239
+ if ($[12] !== density || $[13] !== keyboardNav.onTableBlur || $[14] !== keyboardNav.onTableKeyDown || $[15] !== onRowClick || $[16] !== onRowMouseOut || $[17] !== onRowMouseOver || $[18] !== width) {
240
+ t8 = {
241
+ width,
242
+ density,
243
+ onTableKeyDown: keyboardNav.onTableKeyDown,
244
+ onTableBlur: keyboardNav.onTableBlur,
245
+ onRowClick,
246
+ onRowMouseOver,
247
+ onRowMouseOut
248
+ };
115
249
  $[12] = density;
116
250
  $[13] = keyboardNav.onTableBlur;
117
251
  $[14] = keyboardNav.onTableKeyDown;
118
- $[15] = width;
119
- $[16] = t8;
252
+ $[15] = onRowClick;
253
+ $[16] = onRowMouseOut;
254
+ $[17] = onRowMouseOver;
255
+ $[18] = width;
256
+ $[19] = t8;
120
257
  } else {
121
- t8 = $[16];
258
+ t8 = $[19];
122
259
  }
260
+ const tableContext = t8;
123
261
  let t9;
124
- if ($[17] !== density || $[18] !== onRowClick || $[19] !== onRowMouseOut || $[20] !== onRowMouseOver || $[21] !== rows) {
125
- t9 = (t10)=>{
126
- const { item: _item, ...props_0 } = t10;
127
- const index = props_0["data-index"];
128
- const row = rows[index];
129
- if (!row) {
130
- return null;
131
- }
132
- const rowEventOpts = {
133
- id: row.id,
134
- index: row.index
135
- };
136
- return /*#__PURE__*/ _jsx(TableRow, {
137
- ...props_0,
138
- onClick: (e)=>onRowClick(e, row),
139
- density: density,
140
- onMouseOver: (e_0)=>{
141
- onRowMouseOver?.(e_0, rowEventOpts);
142
- },
143
- onMouseOut: (e_1)=>{
144
- onRowMouseOut?.(e_1, rowEventOpts);
145
- }
146
- });
147
- };
148
- $[17] = density;
149
- $[18] = onRowClick;
150
- $[19] = onRowMouseOut;
151
- $[20] = onRowMouseOver;
152
- $[21] = rows;
153
- $[22] = t9;
154
- } else {
155
- t9 = $[22];
156
- }
157
- let t10;
158
- if ($[23] !== t8 || $[24] !== t9) {
159
- t10 = {
160
- Scroller: VirtualizedTableContainer,
161
- Table: t8,
162
- TableHead,
163
- TableFoot,
164
- TableRow: t9,
165
- TableBody
166
- };
167
- $[23] = t8;
168
- $[24] = t9;
169
- $[25] = t10;
170
- } else {
171
- t10 = $[25];
172
- }
173
- const VirtuosoTableComponents = t10;
174
- let t11;
175
- if ($[26] !== onPaginationChange || $[27] !== pagination) {
176
- t11 = (_event, newPage)=>{
262
+ if ($[20] !== onPaginationChange || $[21] !== pagination) {
263
+ t9 = (_event, newPage)=>{
177
264
  if (!pagination || !onPaginationChange) {
178
265
  return;
179
266
  }
@@ -182,16 +269,16 @@ export function VirtualizedTable(t0) {
182
269
  pageIndex: newPage
183
270
  });
184
271
  };
185
- $[26] = onPaginationChange;
186
- $[27] = pagination;
187
- $[28] = t11;
272
+ $[20] = onPaginationChange;
273
+ $[21] = pagination;
274
+ $[22] = t9;
188
275
  } else {
189
- t11 = $[28];
276
+ t9 = $[22];
190
277
  }
191
- const handleChangePage = t11;
192
- let t12;
193
- if ($[29] !== onPaginationChange || $[30] !== pagination) {
194
- t12 = (event)=>{
278
+ const handleChangePage = t9;
279
+ let t10;
280
+ if ($[23] !== onPaginationChange || $[24] !== pagination) {
281
+ t10 = (event)=>{
195
282
  if (!pagination || !onPaginationChange) {
196
283
  return;
197
284
  }
@@ -200,15 +287,15 @@ export function VirtualizedTable(t0) {
200
287
  pageSize: parseInt(event.target.value, 10)
201
288
  });
202
289
  };
203
- $[29] = onPaginationChange;
204
- $[30] = pagination;
205
- $[31] = t12;
290
+ $[23] = onPaginationChange;
291
+ $[24] = pagination;
292
+ $[25] = t10;
206
293
  } else {
207
- t12 = $[31];
294
+ t10 = $[25];
208
295
  }
209
- const handleChangeRowsPerPage = t12;
296
+ const handleChangeRowsPerPage = t10;
210
297
  let columnSizeVars;
211
- if ($[32] !== table) {
298
+ if ($[26] !== table) {
212
299
  columnSizeVars = {};
213
300
  table.getHeaderGroups().forEach((headerGroup)=>{
214
301
  headerGroup.headers.filter(_temp).forEach((header_0)=>{
@@ -216,40 +303,40 @@ export function VirtualizedTable(t0) {
216
303
  columnSizeVars[`--col-${header_0.column.id}-size`] = header_0.column.getSize();
217
304
  });
218
305
  });
219
- $[32] = table;
220
- $[33] = columnSizeVars;
306
+ $[26] = table;
307
+ $[27] = columnSizeVars;
221
308
  } else {
222
- columnSizeVars = $[33];
309
+ columnSizeVars = $[27];
223
310
  }
224
- let t13;
225
- if ($[34] !== columnSizeVars || $[35] !== height || $[36] !== width) {
226
- t13 = {
311
+ let t11;
312
+ if ($[28] !== columnSizeVars || $[29] !== height || $[30] !== width) {
313
+ t11 = {
227
314
  width,
228
315
  height,
229
316
  ...columnSizeVars
230
317
  };
231
- $[34] = columnSizeVars;
232
- $[35] = height;
233
- $[36] = width;
234
- $[37] = t13;
318
+ $[28] = columnSizeVars;
319
+ $[29] = height;
320
+ $[30] = width;
321
+ $[31] = t11;
235
322
  } else {
236
- t13 = $[37];
323
+ t11 = $[31];
237
324
  }
238
- let t14;
239
- if ($[38] !== toolbarConfig || $[39] !== width) {
240
- t14 = /*#__PURE__*/ _jsx(TableToolbar, {
325
+ let t12;
326
+ if ($[32] !== toolbarConfig || $[33] !== width) {
327
+ t12 = /*#__PURE__*/ _jsx(TableToolbar, {
241
328
  ...toolbarConfig,
242
329
  width: width
243
330
  });
244
- $[38] = toolbarConfig;
245
- $[39] = width;
246
- $[40] = t14;
331
+ $[32] = toolbarConfig;
332
+ $[33] = width;
333
+ $[34] = t12;
247
334
  } else {
248
- t14 = $[40];
335
+ t12 = $[34];
249
336
  }
250
- let t15;
251
- if ($[41] !== defaultColumnHeight || $[42] !== defaultColumnWidth || $[43] !== density || $[44] !== getFocusState || $[45] !== keyboardNav || $[46] !== table) {
252
- t15 = ()=>/*#__PURE__*/ _jsx(_Fragment, {
337
+ let t13;
338
+ if ($[35] !== defaultColumnHeight || $[36] !== defaultColumnWidth || $[37] !== density || $[38] !== getFocusState || $[39] !== keyboardNav || $[40] !== table) {
339
+ t13 = ()=>/*#__PURE__*/ _jsx(_Fragment, {
253
340
  children: table.getHeaderGroups().map((headerGroup_0)=>/*#__PURE__*/ _jsx(TableRow, {
254
341
  density: density,
255
342
  children: headerGroup_0.headers.map((header_1, i, headers)=>{
@@ -284,19 +371,19 @@ export function VirtualizedTable(t0) {
284
371
  })
285
372
  }, headerGroup_0.id))
286
373
  });
287
- $[41] = defaultColumnHeight;
288
- $[42] = defaultColumnWidth;
289
- $[43] = density;
290
- $[44] = getFocusState;
291
- $[45] = keyboardNav;
292
- $[46] = table;
293
- $[47] = t15;
374
+ $[35] = defaultColumnHeight;
375
+ $[36] = defaultColumnWidth;
376
+ $[37] = density;
377
+ $[38] = getFocusState;
378
+ $[39] = keyboardNav;
379
+ $[40] = table;
380
+ $[41] = t13;
294
381
  } else {
295
- t15 = $[47];
382
+ t13 = $[41];
296
383
  }
297
- let t16;
298
- if ($[48] !== handleChangePage || $[49] !== handleChangeRowsPerPage || $[50] !== pagination || $[51] !== table) {
299
- t16 = pagination ? ()=>/*#__PURE__*/ _jsx(MuiTableRow, {
384
+ let t14;
385
+ if ($[42] !== handleChangePage || $[43] !== handleChangeRowsPerPage || $[44] !== pagination || $[45] !== table) {
386
+ t14 = pagination ? ()=>/*#__PURE__*/ _jsx(MuiTableRow, {
300
387
  sx: {
301
388
  backgroundColor: _temp2
302
389
  },
@@ -309,25 +396,25 @@ export function VirtualizedTable(t0) {
309
396
  onRowsPerPageChange: handleChangeRowsPerPage
310
397
  })
311
398
  }) : undefined;
312
- $[48] = handleChangePage;
313
- $[49] = handleChangeRowsPerPage;
314
- $[50] = pagination;
315
- $[51] = table;
316
- $[52] = t16;
399
+ $[42] = handleChangePage;
400
+ $[43] = handleChangeRowsPerPage;
401
+ $[44] = pagination;
402
+ $[45] = table;
403
+ $[46] = t14;
317
404
  } else {
318
- t16 = $[52];
405
+ t14 = $[46];
319
406
  }
320
- let t17;
321
- if ($[53] !== cellConfigs || $[54] !== defaultColumnHeight || $[55] !== defaultColumnWidth || $[56] !== density || $[57] !== getFocusState || $[58] !== keyboardNav || $[59] !== table) {
322
- t17 = (index_0)=>{
323
- const row_0 = table.getRowModel().rows[index_0];
324
- if (!row_0) {
407
+ let t15;
408
+ if ($[47] !== cellConfigs || $[48] !== defaultColumnHeight || $[49] !== defaultColumnWidth || $[50] !== density || $[51] !== getFocusState || $[52] !== keyboardNav || $[53] !== table) {
409
+ t15 = (index)=>{
410
+ const row = table.getRowModel().rows[index];
411
+ if (!row) {
325
412
  return null;
326
413
  }
327
414
  return /*#__PURE__*/ _jsx(_Fragment, {
328
- children: row_0.getVisibleCells().map((cell, i_0, cells)=>{
415
+ children: row.getVisibleCells().map((cell, i_0, cells)=>{
329
416
  const position_0 = {
330
- row: index_0 + 1,
417
+ row: index + 1,
331
418
  column: i_0
332
419
  };
333
420
  const cellContext = cell.getContext();
@@ -343,7 +430,7 @@ export function VirtualizedTable(t0) {
343
430
  description = cellContent;
344
431
  }
345
432
  }
346
- const adjacentCellsValuesMap = Object.entries(row_0.original)?.filter(_temp3).reduce(_temp4, {});
433
+ const adjacentCellsValuesMap = Object.entries(row.original)?.filter(_temp3).reduce(_temp4, {});
347
434
  return /*#__PURE__*/ _jsx(TableCell, {
348
435
  "data-testid": cell.id,
349
436
  title: description || cellConfig?.text || cellContent,
@@ -365,54 +452,55 @@ export function VirtualizedTable(t0) {
365
452
  })
366
453
  });
367
454
  };
368
- $[53] = cellConfigs;
369
- $[54] = defaultColumnHeight;
370
- $[55] = defaultColumnWidth;
371
- $[56] = density;
372
- $[57] = getFocusState;
373
- $[58] = keyboardNav;
374
- $[59] = table;
375
- $[60] = t17;
455
+ $[47] = cellConfigs;
456
+ $[48] = defaultColumnHeight;
457
+ $[49] = defaultColumnWidth;
458
+ $[50] = density;
459
+ $[51] = getFocusState;
460
+ $[52] = keyboardNav;
461
+ $[53] = table;
462
+ $[54] = t15;
376
463
  } else {
377
- t17 = $[60];
464
+ t15 = $[54];
378
465
  }
379
- let t18;
380
- if ($[61] !== VirtuosoTableComponents || $[62] !== rows.length || $[63] !== t15 || $[64] !== t16 || $[65] !== t17) {
381
- t18 = /*#__PURE__*/ _jsx(TableVirtuoso, {
466
+ let t16;
467
+ if ($[55] !== rows || $[56] !== t13 || $[57] !== t14 || $[58] !== t15 || $[59] !== tableContext) {
468
+ t16 = /*#__PURE__*/ _jsx(TableVirtuoso, {
382
469
  ref: virtuosoRef,
383
- totalCount: rows.length,
470
+ data: rows,
384
471
  components: VirtuosoTableComponents,
472
+ context: tableContext,
385
473
  rangeChanged: setVisibleRange,
386
- fixedHeaderContent: t15,
387
- fixedFooterContent: t16,
388
- itemContent: t17
474
+ fixedHeaderContent: t13,
475
+ fixedFooterContent: t14,
476
+ itemContent: t15
389
477
  });
390
- $[61] = VirtuosoTableComponents;
391
- $[62] = rows.length;
392
- $[63] = t15;
393
- $[64] = t16;
394
- $[65] = t17;
395
- $[66] = t18;
478
+ $[55] = rows;
479
+ $[56] = t13;
480
+ $[57] = t14;
481
+ $[58] = t15;
482
+ $[59] = tableContext;
483
+ $[60] = t16;
396
484
  } else {
397
- t18 = $[66];
485
+ t16 = $[60];
398
486
  }
399
- let t19;
400
- if ($[67] !== t13 || $[68] !== t14 || $[69] !== t18) {
401
- t19 = /*#__PURE__*/ _jsxs(Box, {
402
- style: t13,
487
+ let t17;
488
+ if ($[61] !== t11 || $[62] !== t12 || $[63] !== t16) {
489
+ t17 = /*#__PURE__*/ _jsxs(Box, {
490
+ style: t11,
403
491
  children: [
404
- t14,
405
- t18
492
+ t12,
493
+ t16
406
494
  ]
407
495
  });
408
- $[67] = t13;
409
- $[68] = t14;
410
- $[69] = t18;
411
- $[70] = t19;
496
+ $[61] = t11;
497
+ $[62] = t12;
498
+ $[63] = t16;
499
+ $[64] = t17;
412
500
  } else {
413
- t19 = $[70];
501
+ t17 = $[64];
414
502
  }
415
- return t19;
503
+ return t17;
416
504
  }
417
505
  function _temp4(acc, t0) {
418
506
  const [key, value_0] = t0;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Table/VirtualizedTable.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, TablePagination, TableRow as MuiTableRow } from '@mui/material';\nimport type { ReactTable, Row, RowData } from '@tanstack/react-table';\nimport { flexRender } from '@tanstack/react-table';\nimport type { ReactElement } from 'react';\nimport { useMemo, useRef } from 'react';\nimport type { TableComponents, TableVirtuosoHandle, TableVirtuosoProps } from 'react-virtuoso';\nimport { TableVirtuoso } from 'react-virtuoso';\n\nimport { useVirtualizedTableKeyboardNav } from './hooks/useVirtualizedTableKeyboardNav';\nimport { InnerTable } from './InnerTable';\nimport type { TableCellConfigs, TableFeatures, TableProps, TableRowEventOpts } from './model/table-model';\nimport { TableBody } from './TableBody';\nimport type { TableCellProps } from './TableCell';\nimport { TableCell } from './TableCell';\nimport { TableFoot } from './TableFoot';\nimport { TableHead } from './TableHead';\nimport { TableHeaderCell } from './TableHeaderCell';\nimport { TableRow } from './TableRow';\nimport type { TableToolbarProps } from './TableToolbar';\nimport { TableToolbar } from './TableToolbar';\nimport { VirtualizedTableContainer } from './VirtualizedTableContainer';\n\ntype TableCellPosition = {\n row: number;\n column: number;\n};\n\nexport type VirtualizedTableProps<TableData extends RowData> = Required<\n Pick<TableProps<TableData>, 'height' | 'width' | 'density' | 'defaultColumnHeight' | 'defaultColumnWidth'>\n> &\n Pick<TableProps<TableData>, 'onRowMouseOver' | 'onRowMouseOut' | 'pagination' | 'onPaginationChange'> & {\n onRowClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: Row<TableFeatures, TableData>) => void;\n /**\n * The value returned by `useTable`. Its identity changes whenever table\n * state or options change, unlike the row, column, and header objects it\n * returns, which keep their identities across state changes.\n */\n table: ReactTable<TableFeatures, TableData>;\n cellConfigs?: TableCellConfigs;\n toolbarConfig: Pick<\n TableToolbarProps<TableData>,\n | 'isSearchEnabled'\n | 'globalFilter'\n | 'onGlobalFilterChange'\n | 'isColumnFilterEnabled'\n | 'columns'\n | 'columnFilterMenuMaxHeight'\n | 'isExpandAllEnabled'\n | 'isAllExpanded'\n | 'onExpandAllChange'\n >;\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 extends RowData>({\n width,\n height,\n density,\n defaultColumnWidth,\n defaultColumnHeight,\n onRowClick,\n onRowMouseOver,\n onRowMouseOut,\n table,\n cellConfigs,\n pagination,\n onPaginationChange,\n toolbarConfig,\n}: VirtualizedTableProps<TableData>): ReactElement {\n // Rows, columns, and headers keep their identities when table state such as\n // selection, sorting, or sizing changes. Anything that reads that state\n // through their methods must call `table` directly in the same expression or\n // callback, so the React Compiler invalidates it whenever `table` changes.\n const rows = table.getRowModel().rows;\n const columnCount = table.getVisibleFlatColumns().length;\n\n const virtuosoRef = useRef<TableVirtuosoHandle>(null);\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\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: columnCount,\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<Row<TableFeatures, TableData>> = useMemo(() => {\n return {\n Scroller: VirtualizedTableContainer,\n Table: (props): ReactElement => {\n return (\n <InnerTable\n {...props}\n width={width}\n density={density}\n onKeyDown={keyboardNav.onTableKeyDown}\n onBlur={keyboardNav.onTableBlur}\n />\n );\n },\n TableHead,\n TableFoot,\n TableRow: ({ item: _item, ...props }): ReactElement | null => {\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)}\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 }, [\n density,\n keyboardNav.onTableKeyDown,\n keyboardNav.onTableBlur,\n onRowClick,\n onRowMouseOut,\n onRowMouseOver,\n rows,\n width,\n ]);\n\n const handleChangePage = (_event: React.MouseEvent<HTMLButtonElement> | null, newPage: number): void => {\n if (!pagination || !onPaginationChange) return;\n onPaginationChange({ ...pagination, pageIndex: newPage });\n };\n\n const handleChangeRowsPerPage = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {\n if (!pagination || !onPaginationChange) return;\n onPaginationChange({ pageIndex: 0, pageSize: parseInt(event.target.value, 10) });\n };\n\n /**\n * Instead of calling `column.getSize()` on every render for every header\n * and especially every data cell (very expensive),\n * we calculate all column sizes once per render at the root table level\n * and pass the column sizes down as CSS variables to the <table> element.\n */\n const columnSizeVars: { [key: string]: number } = {};\n table.getHeaderGroups().forEach((headerGroup) => {\n headerGroup.headers\n .filter((header) => header.column.getCanResize())\n .forEach((header) => {\n columnSizeVars[`--header-${header.id}-size`] = header.getSize();\n columnSizeVars[`--col-${header.column.id}-size`] = header.column.getSize();\n });\n });\n\n return (\n <Box style={{ width, height, ...columnSizeVars }}>\n <TableToolbar {...toolbarConfig} width={width} />\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 {table.getHeaderGroups().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={\n header.column.getCanResize()\n ? `calc(var(--header-${header?.id}-size) * 1px)`\n : column.getSize() || defaultColumnWidth\n }\n defaultColumnHeight={defaultColumnHeight}\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 resizeConfig={\n header.column.getCanResize()\n ? {\n resizeHandler: header.getResizeHandler(),\n resetSizeHandler: () => header.column.resetSize(),\n isResizing: header.column.getIsResizing(),\n }\n : undefined\n }\n >\n {flexRender(column.columnDef.header, header.getContext())}\n </TableHeaderCell>\n );\n })}\n </TableRow>\n );\n })}\n </>\n );\n }}\n fixedFooterContent={\n pagination\n ? (): ReactElement => (\n <MuiTableRow sx={{ backgroundColor: (theme) => theme.palette.background.default }}>\n <TablePagination\n colSpan={table.getVisibleFlatColumns().length}\n count={table.getRowCount()}\n page={pagination.pageIndex}\n rowsPerPage={pagination.pageSize}\n onPageChange={handleChangePage}\n onRowsPerPageChange={handleChangeRowsPerPage}\n />\n </MuiTableRow>\n )\n : undefined\n }\n itemContent={(index) => {\n const row = table.getRowModel().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 row: index + 1,\n column: i,\n };\n\n const cellContext = cell.getContext();\n const cellConfig = cellConfigs?.[cellContext.cell.id];\n\n const cellRenderFn = cell.column.columnDef.cell;\n const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;\n\n /*\n IMPORTANT:\n If Variables exist in the link, they should have been translated by the plugin already. (Being developed at the moment)\n Components have no access to any context (Which is intentional and correct)\n We may want to add parameters to a link from neighboring cells in the future as well.\n If this is the case, the value of the neighboring cells should be read from here and be replaced. (Bing discussed at the moment, not decided yet)\n */\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 /* this has been specifically added for the data link,\n therefore, non string and numeric values should be excluded\n */\n const adjacentCellsValuesMap = Object.entries(row.original as Record<string, unknown>)\n ?.filter(([_, value]) => ['string', 'number'].includes(typeof value))\n .reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: String(value),\n }),\n {},\n );\n\n return (\n <TableCell\n key={cell.id}\n data-testid={cell.id}\n title={description || cellConfig?.text || cellContent}\n width={\n cell.column.getCanResize()\n ? `calc(var(--col-${cell.column.id}-size) * 1px)`\n : cell.column.getSize() || defaultColumnWidth\n }\n defaultColumnHeight={defaultColumnHeight}\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 color={cellConfig?.textColor ?? undefined}\n backgroundColor={cellConfig?.backgroundColor ?? undefined}\n dataLink={cell.column.columnDef.meta?.dataLink}\n adjacentCellsValuesMap={adjacentCellsValuesMap}\n >\n {cellConfig?.text || cellContent}\n </TableCell>\n );\n })}\n </>\n );\n }}\n />\n </Box>\n );\n}\n"],"names":["Box","TablePagination","TableRow","MuiTableRow","flexRender","useRef","TableVirtuoso","useVirtualizedTableKeyboardNav","InnerTable","TableBody","TableCell","TableFoot","TableHead","TableHeaderCell","TableToolbar","VirtualizedTableContainer"],"mappings":";;AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,eAAe,EAAEC,YAAYC,WAAW,QAAQ,gBAAgB;AAE9E,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAAkBC,MAAM,QAAQ,QAAQ;AAExC,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,8BAA8B,QAAQ,4CAAyC;AACxF,SAASC,UAAU,QAAQ,kBAAe;AAE1C,SAASC,SAAS,QAAQ,iBAAc;AAExC,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASX,QAAQ,QAAQ,gBAAa;AAEtC,SAASY,YAAY,QAAQ,oBAAiB;AAC9C,SAASC,yBAAyB,QAAQ,iCAA8B;AAiCxE,6EAA6E;AAC7E,4EAA4E;AAC5E,mBAAmB;AACnB,OAAO"}
1
+ {"version":3,"sources":["../../src/Table/VirtualizedTable.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, TablePagination, TableRow as MuiTableRow } from '@mui/material';\nimport type { ReactTable, Row, RowData } from '@tanstack/react-table';\nimport { flexRender } from '@tanstack/react-table';\nimport type { ReactElement } from 'react';\nimport { forwardRef, useMemo, useRef } from 'react';\nimport type { TableComponents, TableVirtuosoHandle, TableVirtuosoProps } from 'react-virtuoso';\nimport { TableVirtuoso } from 'react-virtuoso';\n\nimport { useVirtualizedTableKeyboardNav } from './hooks/useVirtualizedTableKeyboardNav';\nimport { InnerTable } from './InnerTable';\nimport type { TableCellConfigs, TableFeatures, TableProps, TableRowEventOpts } from './model/table-model';\nimport { TableBody } from './TableBody';\nimport type { TableCellProps } from './TableCell';\nimport { TableCell } from './TableCell';\nimport { TableFoot } from './TableFoot';\nimport { TableHead } from './TableHead';\nimport { TableHeaderCell } from './TableHeaderCell';\nimport { TableRow } from './TableRow';\nimport type { TableToolbarProps } from './TableToolbar';\nimport { TableToolbar } from './TableToolbar';\nimport { VirtualizedTableContainer } from './VirtualizedTableContainer';\n\ntype TableCellPosition = {\n row: number;\n column: number;\n};\n\ntype TableContext<TableData extends RowData> = {\n width: number | string;\n density: VirtualizedTableProps<TableData>['density'];\n onTableKeyDown: React.KeyboardEventHandler<HTMLTableElement>;\n onTableBlur: React.FocusEventHandler<HTMLTableElement>;\n onRowClick: VirtualizedTableProps<TableData>['onRowClick'];\n onRowMouseOver: VirtualizedTableProps<TableData>['onRowMouseOver'];\n onRowMouseOut: VirtualizedTableProps<TableData>['onRowMouseOut'];\n};\n\n// Defined outside VirtualizedTable so the object reference is stable and\n// TableVirtuoso never remounts its internal components due to a changed prop.\n// Props that vary per-render are passed via the `context` prop instead.\nconst VirtuosoTableComponents: TableComponents<Row<TableFeatures, RowData>, TableContext<RowData>> = {\n Scroller: forwardRef(({ context: _, ...props }, ref) => <VirtualizedTableContainer {...props} ref={ref} />),\n Table: ({ context, ...props }): ReactElement => (\n <InnerTable\n {...props}\n width={context.width}\n density={context.density}\n onKeyDown={context.onTableKeyDown}\n onBlur={context.onTableBlur}\n />\n ),\n TableHead: forwardRef(({ context: _, ...props }, ref) => <TableHead {...props} ref={ref} />),\n TableFoot: forwardRef(({ context: _, ...props }, ref) => <TableFoot {...props} ref={ref} />),\n TableRow: ({ item, context, ...props }): ReactElement | null => {\n if (!item) {\n return null;\n }\n\n const rowEventOpts: TableRowEventOpts = { id: item.id, index: item.index };\n\n return (\n <TableRow\n {...props}\n onClick={(e) => context.onRowClick(e, item)}\n density={context.density}\n onMouseOver={(e) => {\n context.onRowMouseOver?.(e, rowEventOpts);\n }}\n onMouseOut={(e) => {\n context.onRowMouseOut?.(e, rowEventOpts);\n }}\n />\n );\n },\n TableBody: forwardRef(({ context: _, ...props }, ref) => <TableBody {...props} ref={ref} />),\n};\n\nexport type VirtualizedTableProps<TableData extends RowData> = Required<\n Pick<TableProps<TableData>, 'height' | 'width' | 'density' | 'defaultColumnHeight' | 'defaultColumnWidth'>\n> &\n Pick<TableProps<TableData>, 'onRowMouseOver' | 'onRowMouseOut' | 'pagination' | 'onPaginationChange'> & {\n onRowClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: Row<TableFeatures, TableData>) => void;\n /**\n * The value returned by `useTable`. Its identity changes whenever table\n * state or options change, unlike the row, column, and header objects it\n * returns, which keep their identities across state changes.\n */\n table: ReactTable<TableFeatures, TableData>;\n cellConfigs?: TableCellConfigs;\n toolbarConfig: Pick<\n TableToolbarProps<TableData>,\n | 'isSearchEnabled'\n | 'globalFilter'\n | 'onGlobalFilterChange'\n | 'isColumnFilterEnabled'\n | 'columns'\n | 'columnFilterMenuMaxHeight'\n | 'isExpandAllEnabled'\n | 'isAllExpanded'\n | 'onExpandAllChange'\n >;\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 extends RowData>({\n width,\n height,\n density,\n defaultColumnWidth,\n defaultColumnHeight,\n onRowClick,\n onRowMouseOver,\n onRowMouseOut,\n table,\n cellConfigs,\n pagination,\n onPaginationChange,\n toolbarConfig,\n}: VirtualizedTableProps<TableData>): ReactElement {\n // Rows, columns, and headers keep their identities when table state such as\n // selection, sorting, or sizing changes. Anything that reads that state\n // through their methods must call `table` directly in the same expression or\n // callback, so the React Compiler invalidates it whenever `table` changes.\n const rows = table.getRowModel().rows;\n const columnCount = table.getVisibleFlatColumns().length;\n\n const virtuosoRef = useRef<TableVirtuosoHandle>(null);\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\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: columnCount,\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 tableContext: TableContext<TableData> = useMemo(\n () => ({\n width,\n density,\n onTableKeyDown: keyboardNav.onTableKeyDown,\n onTableBlur: keyboardNav.onTableBlur,\n onRowClick,\n onRowMouseOver,\n onRowMouseOut,\n }),\n [width, density, keyboardNav.onTableKeyDown, keyboardNav.onTableBlur, onRowClick, onRowMouseOver, onRowMouseOut],\n );\n\n const handleChangePage = (_event: React.MouseEvent<HTMLButtonElement> | null, newPage: number): void => {\n if (!pagination || !onPaginationChange) return;\n onPaginationChange({ ...pagination, pageIndex: newPage });\n };\n\n const handleChangeRowsPerPage = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {\n if (!pagination || !onPaginationChange) return;\n onPaginationChange({ pageIndex: 0, pageSize: parseInt(event.target.value, 10) });\n };\n\n /**\n * Instead of calling `column.getSize()` on every render for every header\n * and especially every data cell (very expensive),\n * we calculate all column sizes once per render at the root table level\n * and pass the column sizes down as CSS variables to the <table> element.\n */\n const columnSizeVars: { [key: string]: number } = {};\n table.getHeaderGroups().forEach((headerGroup) => {\n headerGroup.headers\n .filter((header) => header.column.getCanResize())\n .forEach((header) => {\n columnSizeVars[`--header-${header.id}-size`] = header.getSize();\n columnSizeVars[`--col-${header.column.id}-size`] = header.column.getSize();\n });\n });\n\n return (\n <Box style={{ width, height, ...columnSizeVars }}>\n <TableToolbar {...toolbarConfig} width={width} />\n <TableVirtuoso\n ref={virtuosoRef}\n data={rows}\n components={VirtuosoTableComponents as TableComponents<Row<TableFeatures, TableData>, TableContext<TableData>>}\n context={tableContext}\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 {table.getHeaderGroups().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={\n header.column.getCanResize()\n ? `calc(var(--header-${header?.id}-size) * 1px)`\n : column.getSize() || defaultColumnWidth\n }\n defaultColumnHeight={defaultColumnHeight}\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 resizeConfig={\n header.column.getCanResize()\n ? {\n resizeHandler: header.getResizeHandler(),\n resetSizeHandler: () => header.column.resetSize(),\n isResizing: header.column.getIsResizing(),\n }\n : undefined\n }\n >\n {flexRender(column.columnDef.header, header.getContext())}\n </TableHeaderCell>\n );\n })}\n </TableRow>\n );\n })}\n </>\n );\n }}\n fixedFooterContent={\n pagination\n ? (): ReactElement => (\n <MuiTableRow sx={{ backgroundColor: (theme) => theme.palette.background.default }}>\n <TablePagination\n colSpan={table.getVisibleFlatColumns().length}\n count={table.getRowCount()}\n page={pagination.pageIndex}\n rowsPerPage={pagination.pageSize}\n onPageChange={handleChangePage}\n onRowsPerPageChange={handleChangeRowsPerPage}\n />\n </MuiTableRow>\n )\n : undefined\n }\n itemContent={(index) => {\n const row = table.getRowModel().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 row: index + 1,\n column: i,\n };\n\n const cellContext = cell.getContext();\n const cellConfig = cellConfigs?.[cellContext.cell.id];\n\n const cellRenderFn = cell.column.columnDef.cell;\n const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;\n\n /*\n IMPORTANT:\n If Variables exist in the link, they should have been translated by the plugin already. (Being developed at the moment)\n Components have no access to any context (Which is intentional and correct)\n We may want to add parameters to a link from neighboring cells in the future as well.\n If this is the case, the value of the neighboring cells should be read from here and be replaced. (Bing discussed at the moment, not decided yet)\n */\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 /* this has been specifically added for the data link,\n therefore, non string and numeric values should be excluded\n */\n const adjacentCellsValuesMap = Object.entries(row.original as Record<string, unknown>)\n ?.filter(([_, value]) => ['string', 'number'].includes(typeof value))\n .reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: String(value),\n }),\n {},\n );\n\n return (\n <TableCell\n key={cell.id}\n data-testid={cell.id}\n title={description || cellConfig?.text || cellContent}\n width={\n cell.column.getCanResize()\n ? `calc(var(--col-${cell.column.id}-size) * 1px)`\n : cell.column.getSize() || defaultColumnWidth\n }\n defaultColumnHeight={defaultColumnHeight}\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 color={cellConfig?.textColor ?? undefined}\n backgroundColor={cellConfig?.backgroundColor ?? undefined}\n dataLink={cell.column.columnDef.meta?.dataLink}\n adjacentCellsValuesMap={adjacentCellsValuesMap}\n >\n {cellConfig?.text || cellContent}\n </TableCell>\n );\n })}\n </>\n );\n }}\n />\n </Box>\n );\n}\n"],"names":["Box","TablePagination","TableRow","MuiTableRow","flexRender","forwardRef","useRef","TableVirtuoso","useVirtualizedTableKeyboardNav","InnerTable","TableBody","TableCell","TableFoot","TableHead","TableHeaderCell","TableToolbar","VirtualizedTableContainer","VirtuosoTableComponents","Scroller","Table","context","props","width","density","onKeyDown","onTableKeyDown","onBlur","onTableBlur","item","rowEventOpts","id","index","onClick","e","onRowClick","onMouseOver","onRowMouseOver","onMouseOut","onRowMouseOut"],"mappings":";;AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,eAAe,EAAEC,YAAYC,WAAW,QAAQ,gBAAgB;AAE9E,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,UAAU,EAAWC,MAAM,QAAQ,QAAQ;AAEpD,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,8BAA8B,QAAQ,4CAAyC;AACxF,SAASC,UAAU,QAAQ,kBAAe;AAE1C,SAASC,SAAS,QAAQ,iBAAc;AAExC,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASZ,QAAQ,QAAQ,gBAAa;AAEtC,SAASa,YAAY,QAAQ,oBAAiB;AAC9C,SAASC,yBAAyB,QAAQ,iCAA8B;AAiBxE,yEAAyE;AACzE,8EAA8E;AAC9E,wEAAwE;AACxE,MAAMC,0BAA+F;IACnGC,wBAAUb,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;IACrBc,OAAO,CAAC,EAAEC,OAAO,EAAE,GAAQ,AAALC,OAAO,iBAC3B,KAACZ;YACE,GAAGY,KAAK;YACTC,OAAOF,QAAQE,KAAK;YACpBC,SAASH,QAAQG,OAAO;YACxBC,WAAWJ,QAAQK,cAAc;YACjCC,QAAQN,QAAQO,WAAW;;IAG/Bd,yBAAWR,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;IACtBO,yBAAWP,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;IACtBH,UAAU,CAAC,EAAE0B,IAAI,EAAER,OAAO,EAAE,GAAQ,AAALC,OAAO;QACpC,IAAI,CAACO,MAAM;YACT,OAAO;QACT;QAEA,MAAMC,eAAkC;YAAEC,IAAIF,KAAKE,EAAE;YAAEC,OAAOH,KAAKG,KAAK;QAAC;QAEzE,qBACE,KAAC7B;YACE,GAAGmB,KAAK;YACTW,SAAS,CAACC,IAAMb,QAAQc,UAAU,CAACD,GAAGL;YACtCL,SAASH,QAAQG,OAAO;YACxBY,aAAa,CAACF;gBACZb,QAAQgB,cAAc,GAAGH,GAAGJ;YAC9B;YACAQ,YAAY,CAACJ;gBACXb,QAAQkB,aAAa,GAAGL,GAAGJ;YAC7B;;IAGN;IACAnB,yBAAWL,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;AACxB;AA4BA,6EAA6E;AAC7E,4EAA4E;AAC5E,mBAAmB;AACnB,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"useVirtualizedTableKeyboardNav.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useVirtualizedTableKeyboardNav.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,UAAU,mCAAoC,SAAQ,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,CAAC;IACxG,YAAY,EAAE,gBAAgB,CAAC;QAC7B,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,YAAY,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,UAAU,GACX,EAAE,mCAAmC,GAAG;IACvC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACvD,WAAW,EAAE,CAAC,YAAY,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACvD,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAClD,CA4EA"}
1
+ {"version":3,"file":"useVirtualizedTableKeyboardNav.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useVirtualizedTableKeyboardNav.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,UAAU,mCAAoC,SAAQ,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,CAAC;IACxG,YAAY,EAAE,gBAAgB,CAAC;QAC7B,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,YAAY,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,UAAU,GACX,EAAE,mCAAmC,GAAG;IACvC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACvD,WAAW,EAAE,CAAC,YAAY,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACvD,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAClD,CAmFA"}
@@ -11,6 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { c as _c } from "react-compiler-runtime";
14
+ import React from "react";
14
15
  import { useTableKeyboardNav } from "./useTableKeyboardNav.js";
15
16
  /**
16
17
  * Hook for managing keyboard navigation when using a virtualized table.
@@ -83,22 +84,22 @@ import { useTableKeyboardNav } from "./useTableKeyboardNav.js";
83
84
  } else {
84
85
  t1 = $[3];
85
86
  }
87
+ const onActiveCellChange = t1;
86
88
  let t2;
87
- if ($[4] !== maxColumns || $[5] !== maxRows || $[6] !== t1) {
89
+ if ($[4] !== maxColumns || $[5] !== maxRows || $[6] !== onActiveCellChange) {
88
90
  t2 = {
89
91
  maxRows,
90
92
  maxColumns,
91
- onActiveCellChange: t1
93
+ onActiveCellChange
92
94
  };
93
95
  $[4] = maxColumns;
94
96
  $[5] = maxRows;
95
- $[6] = t1;
97
+ $[6] = onActiveCellChange;
96
98
  $[7] = t2;
97
99
  } else {
98
100
  t2 = $[7];
99
101
  }
100
- const baseKeyboard = useTableKeyboardNav(t2);
101
- return baseKeyboard;
102
+ return useTableKeyboardNav(t2);
102
103
  }
103
104
 
104
105
  //# sourceMappingURL=useVirtualizedTableKeyboardNav.js.map