@tanstack/table-core 8.5.8 → 8.5.11

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "8.5.8",
4
+ "version": "8.5.11",
5
5
  "description": "Headless UI for building powerful tables & datagrids for TS/JS.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/tanstack/table#readme",
package/src/types.ts CHANGED
@@ -242,7 +242,7 @@ export type AccessorKeyColumnDef<TData extends RowData, TValue = unknown> = {
242
242
  id?: string
243
243
  } & Partial<ColumnIdentifiers<TData, TValue>> &
244
244
  ColumnDefBase<TData, TValue> & {
245
- accessorKey: DeepKeys<TData>
245
+ accessorKey: string | keyof TData
246
246
  }
247
247
 
248
248
  export type AccessorColumnDef<TData extends RowData, TValue = unknown> =
@@ -14,14 +14,17 @@ export function getExpandedRowModel<TData extends RowData>(): (
14
14
  (expanded, rowModel, paginateExpandedRows) => {
15
15
  if (
16
16
  !rowModel.rows.length ||
17
- // Do not expand if rows are not included in pagination
18
- !paginateExpandedRows ||
19
17
  (expanded !== true && !Object.keys(expanded ?? {}).length)
20
18
  ) {
21
19
  return rowModel
22
20
  }
23
21
 
24
- return expandRows(rowModel, table)
22
+ if (!paginateExpandedRows) {
23
+ // Only expand rows at this point if they are being paginated
24
+ return rowModel
25
+ }
26
+
27
+ return expandRows(rowModel)
25
28
  },
26
29
  {
27
30
  key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
@@ -30,10 +33,7 @@ export function getExpandedRowModel<TData extends RowData>(): (
30
33
  )
31
34
  }
32
35
 
33
- export function expandRows<TData extends RowData>(
34
- rowModel: RowModel<TData>,
35
- table: Table<TData>
36
- ) {
36
+ export function expandRows<TData extends RowData>(rowModel: RowModel<TData>) {
37
37
  const expandedRows: Row<TData>[] = []
38
38
 
39
39
  const handleRow = (row: Row<TData>) => {
@@ -7,7 +7,13 @@ export function getPaginationRowModel<TData extends RowData>(opts?: {
7
7
  }): (table: Table<TData>) => () => RowModel<TData> {
8
8
  return table =>
9
9
  memo(
10
- () => [table.getState().pagination, table.getPrePaginationRowModel()],
10
+ () => [
11
+ table.getState().pagination,
12
+ table.getPrePaginationRowModel(),
13
+ table.options.paginateExpandedRows
14
+ ? undefined
15
+ : table.getState().expanded,
16
+ ],
11
17
  (pagination, rowModel) => {
12
18
  if (!rowModel.rows.length) {
13
19
  return rowModel
@@ -23,14 +29,11 @@ export function getPaginationRowModel<TData extends RowData>(opts?: {
23
29
  let paginatedRowModel: RowModel<TData>
24
30
 
25
31
  if (!table.options.paginateExpandedRows) {
26
- paginatedRowModel = expandRows(
27
- {
28
- rows,
29
- flatRows,
30
- rowsById,
31
- },
32
- table
33
- )
32
+ paginatedRowModel = expandRows({
33
+ rows,
34
+ flatRows,
35
+ rowsById,
36
+ })
34
37
  } else {
35
38
  paginatedRowModel = {
36
39
  rows,