@tanstack/table-core 8.5.6 → 8.5.9

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.6",
4
+ "version": "8.5.9",
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
@@ -240,7 +240,7 @@ export type AccessorFnColumnDef<
240
240
 
241
241
  export type AccessorKeyColumnDef<TData extends RowData, TValue = unknown> = {
242
242
  id?: string
243
- } & ColumnIdentifiers<TData, TValue> &
243
+ } & Partial<ColumnIdentifiers<TData, TValue>> &
244
244
  ColumnDefBase<TData, TValue> & {
245
245
  accessorKey: DeepKeys<TData>
246
246
  }
@@ -14,14 +14,18 @@ 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
+ console.log(rowModel.rows)
25
+ return rowModel
26
+ }
27
+
28
+ return expandRows(rowModel)
25
29
  },
26
30
  {
27
31
  key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
@@ -30,10 +34,7 @@ export function getExpandedRowModel<TData extends RowData>(): (
30
34
  )
31
35
  }
32
36
 
33
- export function expandRows<TData extends RowData>(
34
- rowModel: RowModel<TData>,
35
- table: Table<TData>
36
- ) {
37
+ export function expandRows<TData extends RowData>(rowModel: RowModel<TData>) {
37
38
  const expandedRows: Row<TData>[] = []
38
39
 
39
40
  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,
@@ -39,6 +42,8 @@ export function getPaginationRowModel<TData extends RowData>(opts?: {
39
42
  }
40
43
  }
41
44
 
45
+ console.log(paginatedRowModel.rows)
46
+
42
47
  paginatedRowModel.flatRows = []
43
48
 
44
49
  const handleRow = (row: Row<TData>) => {
package/src/utils.ts CHANGED
@@ -24,11 +24,11 @@ type ComputeRange<
24
24
  > = Result['length'] extends N
25
25
  ? Result
26
26
  : ComputeRange<N, [...Result, Result['length']]>
27
- type Index100 = ComputeRange<100>[number]
27
+ type Index40 = ComputeRange<40>[number]
28
28
 
29
29
  // Is this type a tuple?
30
30
  type IsTuple<T> = T extends readonly any[] & { length: infer Length }
31
- ? Length extends Index100
31
+ ? Length extends Index40
32
32
  ? T
33
33
  : never
34
34
  : never
@@ -48,48 +48,18 @@ export type DeepKeys<T> = unknown extends T
48
48
  : object extends T
49
49
  ? string
50
50
  : T extends readonly any[] & IsTuple<T>
51
- ? AllowedIndexes<T> | DeepKeysPrefix<T>
51
+ ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>>
52
52
  : T extends any[]
53
53
  ? never & 'Dynamic length array indexing is not supported'
54
54
  : T extends Date
55
55
  ? never
56
56
  : T extends object
57
- ? (keyof T & string) | DeepKeysPrefix<T>
57
+ ? (keyof T & string) | DeepKeysPrefix<T, keyof T>
58
58
  : never
59
59
 
60
- type Key = string | number | symbol
61
- type Join<L extends Key | undefined, R extends Key | undefined> = L extends
62
- | string
63
- | number
64
- ? R extends string | number
65
- ? `${L}.${R}`
66
- : L
67
- : R extends string | number
68
- ? R
69
- : undefined
70
- type Union<
71
- L extends unknown | undefined,
72
- R extends unknown | undefined
73
- > = L extends undefined
74
- ? R extends undefined
75
- ? undefined
76
- : R
77
- : R extends undefined
78
- ? L
79
- : L | R
80
- type DeepKeysPrefix<
81
- T extends object,
82
- Prev extends Key | undefined = undefined,
83
- Path extends Key | undefined = undefined,
84
- PrevTypes extends object = T
85
- > = string &
86
- {
87
- [K in keyof T]: T[K] extends PrevTypes | T
88
- ? Union<Union<Prev, Path>, Join<Path, K>>
89
- : T[K] extends object
90
- ? DeepKeysPrefix<T[K], Union<Prev, Path>, Join<Path, K>, PrevTypes | T>
91
- : Union<Union<Prev, Path>, Join<Path, K>>
92
- }[keyof T]
60
+ type DeepKeysPrefix<T, TPrefix> = TPrefix extends keyof T & (number | string)
61
+ ? `${TPrefix}.${DeepKeys<T[TPrefix]> & string}`
62
+ : never
93
63
 
94
64
  export type DeepValue<T, TProp> = T extends Record<string | number, any>
95
65
  ? TProp extends `${infer TBranch}.${infer TDeepProp}`