@tanstack/table-core 8.0.0-alpha.87 → 8.0.0-alpha.88

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,13 +1,13 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "8.0.0-alpha.87",
5
- "description": "Hooks for building lightweight, fast and extendable datagrids for React",
4
+ "version": "8.0.0-alpha.88",
5
+ "description": "Headless UI for building powerful tables & datagrids for TS/JS.",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/tanstack/react-table#readme",
7
+ "homepage": "https://github.com/tanstack/table#readme",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/tanstack/react-table.git"
10
+ "url": "git+https://github.com/tanstack/table.git"
11
11
  },
12
12
  "publishConfig": {
13
13
  "registry": "https://registry.npmjs.org/"
package/src/core/cell.ts CHANGED
@@ -19,8 +19,8 @@ export function createCell<TGenerics extends TableGenerics>(
19
19
  row,
20
20
  column,
21
21
  getValue: () => row.getValue(columnId),
22
- renderCell: () =>
23
- column.columnDef.cell
22
+ renderCell: () => {
23
+ return column.columnDef.cell
24
24
  ? instance._render(column.columnDef.cell, {
25
25
  instance,
26
26
  column,
@@ -28,7 +28,8 @@ export function createCell<TGenerics extends TableGenerics>(
28
28
  cell: cell as Cell<TGenerics>,
29
29
  getValue: cell.getValue,
30
30
  })
31
- : null,
31
+ : null
32
+ },
32
33
  }
33
34
 
34
35
  instance._features.forEach(feature => {
@@ -98,7 +98,6 @@ export function createColumn<TGenerics extends TableGenerics>(
98
98
  }
99
99
 
100
100
  let column: CoreColumn<TGenerics> = {
101
- ...columnDef,
102
101
  id: `${id}`,
103
102
  accessorFn,
104
103
  parent: parent as any,
@@ -131,8 +131,12 @@ export const Expanding: TableFeature = {
131
131
  const expanded = instance.getState().expanded
132
132
 
133
133
  // If expanded is true, save some cycles and return true
134
- if (expanded === true) {
135
- return true
134
+ if (typeof expanded === 'boolean') {
135
+ return expanded === true
136
+ }
137
+
138
+ if (!Object.keys(expanded).length) {
139
+ return false
136
140
  }
137
141
 
138
142
  // If any row is not expanded, return false
@@ -112,15 +112,9 @@ export const Visibility: TableFeature = {
112
112
  ): VisibilityRow<TGenerics> => {
113
113
  return {
114
114
  _getAllVisibleCells: memo(
115
- () => [
116
- row
117
- .getAllCells()
118
- .filter(cell => cell.column.getIsVisible())
119
- .map(d => d.id)
120
- .join('_'),
121
- ],
122
- _ => {
123
- return row.getAllCells().filter(cell => cell.column.getIsVisible())
115
+ () => [row.getAllCells(), instance.getState().columnVisibility],
116
+ cells => {
117
+ return cells.filter(cell => cell.column.getIsVisible())
124
118
  },
125
119
  {
126
120
  key:
package/src/index.ts CHANGED
@@ -5,7 +5,6 @@ export * from './core/column'
5
5
  export * from './core/headers'
6
6
  export * from './core/row'
7
7
  export * from './features/ColumnSizing'
8
- export * from './features/ColumnSizing'
9
8
  export * from './features/Expanding'
10
9
  export * from './features/Filters'
11
10
  export * from './features/Grouping'
@@ -15,7 +14,6 @@ export * from './features/Pinning'
15
14
  export * from './features/RowSelection'
16
15
  export * from './features/Sorting'
17
16
  export * from './features/Visibility'
18
- export * from './features/Expanding'
19
17
  export * from './filterFns'
20
18
  export * from './sortingFns'
21
19
  export * from './aggregationFns'
@@ -21,20 +21,14 @@ export function getCoreRowModel<TGenerics extends TableGenerics>(): (
21
21
  rowsById: {},
22
22
  }
23
23
 
24
- let rows
25
- let row
26
- let originalRow
27
-
28
24
  const accessRows = (
29
25
  originalRows: TGenerics['Row'][],
30
26
  depth = 0,
31
27
  parent?: Row<TGenerics>
32
28
  ): Row<TGenerics>[] => {
33
- rows = []
29
+ const rows = [] as Row<TGenerics>[]
34
30
 
35
31
  for (let i = 0; i < originalRows.length; i++) {
36
- originalRow = originalRows[i]
37
-
38
32
  // This could be an expensive check at scale, so we should move it somewhere else, but where?
39
33
  // if (!id) {
40
34
  // if (process.env.NODE_ENV !== 'production') {
@@ -43,10 +37,10 @@ export function getCoreRowModel<TGenerics extends TableGenerics>(): (
43
37
  // }
44
38
 
45
39
  // Make the row
46
- row = createRow(
40
+ const row = createRow(
47
41
  instance,
48
- instance._getRowId(originalRow, i, parent),
49
- originalRow,
42
+ instance._getRowId(originalRows[i], i, parent),
43
+ originalRows[i],
50
44
  i,
51
45
  depth
52
46
  )
@@ -60,7 +54,10 @@ export function getCoreRowModel<TGenerics extends TableGenerics>(): (
60
54
 
61
55
  // Get the original subrows
62
56
  if (instance.options.getSubRows) {
63
- row.originalSubRows = instance.options.getSubRows(originalRow, i)
57
+ row.originalSubRows = instance.options.getSubRows(
58
+ originalRows[i],
59
+ i
60
+ )
64
61
 
65
62
  // Then recursively access them
66
63
  if (row.originalSubRows?.length) {