@tanstack/table-core 8.0.0-alpha.61 → 8.0.0-alpha.64
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/build/cjs/core.js +21 -14
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +3 -3
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +3 -3
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +10 -8
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +24 -22
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Ordering.js +5 -4
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +4 -4
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +11 -72
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +3 -3
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +5 -5
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +3 -3
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +89 -142
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +357 -339
- package/build/types/core.d.ts +0 -1
- package/build/types/features/Expanding.d.ts +2 -7
- package/build/types/features/Filters.d.ts +3 -14
- package/build/types/features/Grouping.d.ts +3 -11
- package/build/types/features/Ordering.d.ts +2 -6
- package/build/types/features/Pinning.d.ts +2 -15
- package/build/types/features/RowSelection.d.ts +3 -8
- package/build/types/features/Sorting.d.ts +2 -8
- package/build/types/features/Visibility.d.ts +2 -11
- package/build/umd/index.development.js +89 -141
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/core.ts +25 -15
- package/src/features/ColumnSizing.ts +2 -1
- package/src/features/Expanding.ts +4 -2
- package/src/features/Filters.ts +16 -24
- package/src/features/Grouping.ts +23 -21
- package/src/features/Ordering.ts +6 -8
- package/src/features/Pagination.ts +3 -2
- package/src/features/Pinning.ts +6 -74
- package/src/features/RowSelection.ts +5 -3
- package/src/features/Sorting.ts +9 -7
- package/src/features/Visibility.ts +4 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.64",
|
|
5
5
|
"description": "Hooks for building lightweight, fast and extendable datagrids for React",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/react-table#readme",
|
package/src/core.ts
CHANGED
|
@@ -55,7 +55,7 @@ export type TableCore<TGenerics extends TableGenerics> = {
|
|
|
55
55
|
options: RequiredKeys<TableOptions<TGenerics>, 'state'>
|
|
56
56
|
setOptions: (newOptions: Updater<TableOptions<TGenerics>>) => void
|
|
57
57
|
queue: (cb: () => void) => void
|
|
58
|
-
willUpdate: () => void
|
|
58
|
+
// willUpdate: () => void
|
|
59
59
|
getState: () => TableState
|
|
60
60
|
setState: (updater: Updater<TableState>) => void
|
|
61
61
|
render: <TProps>(
|
|
@@ -116,16 +116,17 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
116
116
|
coreProgress: 1,
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
let initialState = {
|
|
120
120
|
...coreInitialState,
|
|
121
121
|
...(options.initialState ?? {}),
|
|
122
|
-
...instance._features.reduce((obj, feature) => {
|
|
123
|
-
return Object.assign(obj, feature.getInitialState?.(options.initialState))
|
|
124
|
-
}, {}),
|
|
125
122
|
} as TableState
|
|
126
123
|
|
|
124
|
+
instance._features.forEach(feature => {
|
|
125
|
+
initialState = feature.getInitialState?.(initialState) ?? initialState
|
|
126
|
+
})
|
|
127
|
+
|
|
127
128
|
const queued: (() => void)[] = []
|
|
128
|
-
let queuedTimeout
|
|
129
|
+
let queuedTimeout = false
|
|
129
130
|
|
|
130
131
|
const finalInstance: TableInstance<TGenerics> = {
|
|
131
132
|
...instance,
|
|
@@ -134,18 +135,27 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
134
135
|
}, {}) as unknown as TableInstance<TGenerics>),
|
|
135
136
|
queue: cb => {
|
|
136
137
|
queued.push(cb)
|
|
138
|
+
|
|
137
139
|
if (!queuedTimeout) {
|
|
138
|
-
queuedTimeout =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
queuedTimeout = true
|
|
141
|
+
|
|
142
|
+
// Schedule a microtask to run the queued callbacks after
|
|
143
|
+
// the current call stack (render, etc) has finished.
|
|
144
|
+
Promise.resolve()
|
|
145
|
+
.then(() => {
|
|
146
|
+
while (queued.length) {
|
|
147
|
+
queued.shift()!()
|
|
148
|
+
}
|
|
149
|
+
queuedTimeout = false
|
|
150
|
+
})
|
|
151
|
+
.catch(error =>
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
throw error
|
|
154
|
+
})
|
|
155
|
+
)
|
|
147
156
|
}
|
|
148
157
|
},
|
|
158
|
+
// willUpdate: () => {},
|
|
149
159
|
initialState,
|
|
150
160
|
reset: () => {
|
|
151
161
|
instance.setState(instance.initialState)
|
|
@@ -98,7 +98,7 @@ export const ColumnSizing: TableFeature = {
|
|
|
98
98
|
getDefaultColumn: (): ColumnSizingColumnDef => {
|
|
99
99
|
return defaultColumnSizing
|
|
100
100
|
},
|
|
101
|
-
getInitialState: (): ColumnSizingTableState => {
|
|
101
|
+
getInitialState: (state): ColumnSizingTableState => {
|
|
102
102
|
return {
|
|
103
103
|
columnSizing: {},
|
|
104
104
|
columnSizingInfo: {
|
|
@@ -109,6 +109,7 @@ export const ColumnSizing: TableFeature = {
|
|
|
109
109
|
isResizingColumn: false,
|
|
110
110
|
columnSizingStart: [],
|
|
111
111
|
},
|
|
112
|
+
...state,
|
|
112
113
|
}
|
|
113
114
|
},
|
|
114
115
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
TableInstance,
|
|
6
6
|
Row,
|
|
7
7
|
Updater,
|
|
8
|
+
TableFeature,
|
|
8
9
|
} from '../types'
|
|
9
10
|
import { makeStateUpdater } from '../utils'
|
|
10
11
|
|
|
@@ -57,10 +58,11 @@ export type ExpandedInstance<TGenerics extends TableGenerics> = {
|
|
|
57
58
|
|
|
58
59
|
//
|
|
59
60
|
|
|
60
|
-
export const Expanding = {
|
|
61
|
-
getInitialState: (): ExpandedTableState => {
|
|
61
|
+
export const Expanding: TableFeature = {
|
|
62
|
+
getInitialState: (state): ExpandedTableState => {
|
|
62
63
|
return {
|
|
63
64
|
expanded: {},
|
|
65
|
+
...state,
|
|
64
66
|
}
|
|
65
67
|
},
|
|
66
68
|
|
package/src/features/Filters.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
TableInstance,
|
|
8
8
|
Row,
|
|
9
9
|
Updater,
|
|
10
|
+
TableFeature,
|
|
10
11
|
} from '../types'
|
|
11
12
|
import {
|
|
12
13
|
functionalUpdate,
|
|
@@ -57,12 +58,8 @@ export type FilterFnOption<TGenerics extends TableGenerics> =
|
|
|
57
58
|
|
|
58
59
|
export type FiltersColumnDef<TGenerics extends TableGenerics> = {
|
|
59
60
|
filterFn?: FilterFnOption<Overwrite<TGenerics, { Value: any }>>
|
|
60
|
-
enableAllFilters?: boolean
|
|
61
61
|
enableColumnFilter?: boolean
|
|
62
62
|
enableGlobalFilter?: boolean
|
|
63
|
-
defaultCanFilter?: boolean
|
|
64
|
-
defaultCanColumnFilter?: boolean
|
|
65
|
-
defaultCanGlobalFilter?: boolean
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
export type FiltersColumn<TGenerics extends TableGenerics> = {
|
|
@@ -81,7 +78,7 @@ export type FiltersColumn<TGenerics extends TableGenerics> = {
|
|
|
81
78
|
export type FiltersOptions<TGenerics extends TableGenerics> = {
|
|
82
79
|
filterFromLeafRows?: boolean
|
|
83
80
|
filterFns?: TGenerics['FilterFns']
|
|
84
|
-
|
|
81
|
+
|
|
85
82
|
// Column
|
|
86
83
|
manualColumnFiltering?: boolean
|
|
87
84
|
onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>
|
|
@@ -89,6 +86,7 @@ export type FiltersOptions<TGenerics extends TableGenerics> = {
|
|
|
89
86
|
getColumnFilteredRowModel?: (
|
|
90
87
|
instance: TableInstance<TGenerics>
|
|
91
88
|
) => () => RowModel<TGenerics>
|
|
89
|
+
|
|
92
90
|
// Global
|
|
93
91
|
manualGlobalFiltering?: boolean
|
|
94
92
|
globalFilterFn?: FilterFnOption<TGenerics>
|
|
@@ -97,7 +95,7 @@ export type FiltersOptions<TGenerics extends TableGenerics> = {
|
|
|
97
95
|
getGlobalFilteredRowModel?: (
|
|
98
96
|
instance: TableInstance<TGenerics>
|
|
99
97
|
) => () => RowModel<TGenerics>
|
|
100
|
-
|
|
98
|
+
getColumnCanGlobalFilter?: (column: Column<TGenerics>) => boolean
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
export type FiltersInstance<TGenerics extends TableGenerics> = {
|
|
@@ -132,7 +130,7 @@ export type FiltersInstance<TGenerics extends TableGenerics> = {
|
|
|
132
130
|
|
|
133
131
|
//
|
|
134
132
|
|
|
135
|
-
export const Filters = {
|
|
133
|
+
export const Filters: TableFeature = {
|
|
136
134
|
getDefaultColumn: <
|
|
137
135
|
TGenerics extends TableGenerics
|
|
138
136
|
>(): FiltersColumnDef<TGenerics> => {
|
|
@@ -141,12 +139,13 @@ export const Filters = {
|
|
|
141
139
|
}
|
|
142
140
|
},
|
|
143
141
|
|
|
144
|
-
getInitialState: (): FiltersTableState => {
|
|
142
|
+
getInitialState: (state): FiltersTableState => {
|
|
145
143
|
return {
|
|
146
144
|
columnFilters: [],
|
|
147
145
|
globalFilter: undefined,
|
|
148
146
|
columnFiltersProgress: 1,
|
|
149
147
|
globalFilterProgress: 1,
|
|
148
|
+
...state,
|
|
150
149
|
}
|
|
151
150
|
},
|
|
152
151
|
|
|
@@ -158,7 +157,7 @@ export const Filters = {
|
|
|
158
157
|
onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
|
|
159
158
|
filterFromLeafRows: true,
|
|
160
159
|
globalFilterFn: 'auto',
|
|
161
|
-
|
|
160
|
+
getColumnCanGlobalFilter: column => {
|
|
162
161
|
const value = instance
|
|
163
162
|
.getCoreRowModel()
|
|
164
163
|
.flatRows[0]?.getAllCellsByColumnId()[column.id]?.value
|
|
@@ -281,6 +280,8 @@ export const Filters = {
|
|
|
281
280
|
const { filterFns: userFilterFns, globalFilterFn: globalFilterFn } =
|
|
282
281
|
instance.options
|
|
283
282
|
|
|
283
|
+
debugger
|
|
284
|
+
|
|
284
285
|
return isFunction(globalFilterFn)
|
|
285
286
|
? globalFilterFn
|
|
286
287
|
: globalFilterFn === 'auto'
|
|
@@ -331,12 +332,8 @@ export const Filters = {
|
|
|
331
332
|
}
|
|
332
333
|
|
|
333
334
|
return (
|
|
334
|
-
column.
|
|
335
|
-
|
|
336
|
-
instance.options.enableFilters ??
|
|
337
|
-
instance.options.enableColumnFilters ??
|
|
338
|
-
column.defaultCanColumnFilter ??
|
|
339
|
-
column.defaultCanFilter ??
|
|
335
|
+
(column.enableColumnFilter ?? true) &&
|
|
336
|
+
(instance.options.enableColumnFilters ?? true) &&
|
|
340
337
|
!!column.accessorFn
|
|
341
338
|
)
|
|
342
339
|
},
|
|
@@ -349,15 +346,10 @@ export const Filters = {
|
|
|
349
346
|
}
|
|
350
347
|
|
|
351
348
|
return (
|
|
352
|
-
(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
column.defaultCanGlobalFilter ??
|
|
357
|
-
column.defaultCanFilter ??
|
|
358
|
-
!!column.accessorFn) &&
|
|
359
|
-
instance.options.getColumnCanGlobalFilterFn?.(column)) ??
|
|
360
|
-
true
|
|
349
|
+
(column.enableGlobalFilter ?? true) &&
|
|
350
|
+
(instance.options.enableGlobalFilter ?? true) &&
|
|
351
|
+
(instance.options.getColumnCanGlobalFilter?.(column) ?? true) &&
|
|
352
|
+
!!column.accessorFn
|
|
361
353
|
)
|
|
362
354
|
},
|
|
363
355
|
|
package/src/features/Grouping.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Updater,
|
|
10
10
|
Renderable,
|
|
11
11
|
TableGenerics,
|
|
12
|
+
TableFeature,
|
|
12
13
|
} from '../types'
|
|
13
14
|
import { isFunction, makeStateUpdater, Overwrite } from '../utils'
|
|
14
15
|
|
|
@@ -116,7 +117,7 @@ export type GroupingInstance<TGenerics extends TableGenerics> = {
|
|
|
116
117
|
|
|
117
118
|
//
|
|
118
119
|
|
|
119
|
-
export const Grouping = {
|
|
120
|
+
export const Grouping: TableFeature = {
|
|
120
121
|
getDefaultColumn: <
|
|
121
122
|
TGenerics extends TableGenerics
|
|
122
123
|
>(): GroupingColumnDef<TGenerics> => {
|
|
@@ -125,9 +126,10 @@ export const Grouping = {
|
|
|
125
126
|
}
|
|
126
127
|
},
|
|
127
128
|
|
|
128
|
-
getInitialState: (): GroupingTableState => {
|
|
129
|
+
getInitialState: (state): GroupingTableState => {
|
|
129
130
|
return {
|
|
130
131
|
grouping: [],
|
|
132
|
+
...state,
|
|
131
133
|
}
|
|
132
134
|
},
|
|
133
135
|
|
|
@@ -302,28 +304,28 @@ export const Grouping = {
|
|
|
302
304
|
},
|
|
303
305
|
}
|
|
304
306
|
},
|
|
307
|
+
}
|
|
305
308
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
309
|
+
export function orderColumns<TGenerics extends TableGenerics>(
|
|
310
|
+
leafColumns: Column<TGenerics>[],
|
|
311
|
+
grouping: string[],
|
|
312
|
+
groupedColumnMode?: GroupingColumnMode
|
|
313
|
+
) {
|
|
314
|
+
if (!grouping?.length || !groupedColumnMode) {
|
|
315
|
+
return leafColumns
|
|
316
|
+
}
|
|
314
317
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
const nonGroupingColumns = leafColumns.filter(
|
|
319
|
+
col => !grouping.includes(col.id)
|
|
320
|
+
)
|
|
318
321
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
+
if (groupedColumnMode === 'remove') {
|
|
323
|
+
return nonGroupingColumns
|
|
324
|
+
}
|
|
322
325
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
+
const groupingColumns = grouping
|
|
327
|
+
.map(g => leafColumns.find(col => col.id === g)!)
|
|
328
|
+
.filter(Boolean)
|
|
326
329
|
|
|
327
|
-
|
|
328
|
-
},
|
|
330
|
+
return [...groupingColumns, ...nonGroupingColumns]
|
|
329
331
|
}
|
package/src/features/Ordering.ts
CHANGED
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
Updater,
|
|
7
7
|
Column,
|
|
8
8
|
TableGenerics,
|
|
9
|
+
TableFeature,
|
|
9
10
|
} from '../types'
|
|
10
11
|
|
|
11
|
-
import { Grouping } from './Grouping'
|
|
12
|
+
import { Grouping, orderColumns } from './Grouping'
|
|
12
13
|
|
|
13
14
|
export type ColumnOrderTableState = {
|
|
14
15
|
columnOrder: ColumnOrderState
|
|
@@ -34,10 +35,11 @@ export type ColumnOrderInstance<TGenerics extends TableGenerics> = {
|
|
|
34
35
|
|
|
35
36
|
//
|
|
36
37
|
|
|
37
|
-
export const Ordering = {
|
|
38
|
-
getInitialState: (): ColumnOrderTableState => {
|
|
38
|
+
export const Ordering: TableFeature = {
|
|
39
|
+
getInitialState: (state): ColumnOrderTableState => {
|
|
39
40
|
return {
|
|
40
41
|
columnOrder: [],
|
|
42
|
+
...state,
|
|
41
43
|
}
|
|
42
44
|
},
|
|
43
45
|
|
|
@@ -95,11 +97,7 @@ export const Ordering = {
|
|
|
95
97
|
orderedColumns = [...orderedColumns, ...columnsCopy]
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
return
|
|
99
|
-
orderedColumns,
|
|
100
|
-
grouping,
|
|
101
|
-
groupedColumnMode
|
|
102
|
-
)
|
|
100
|
+
return orderColumns(orderedColumns, grouping, groupedColumnMode)
|
|
103
101
|
},
|
|
104
102
|
{
|
|
105
103
|
key: 'getOrderColumnsFn',
|
|
@@ -59,13 +59,14 @@ export type PaginationInstance<TGenerics extends TableGenerics> = {
|
|
|
59
59
|
//
|
|
60
60
|
|
|
61
61
|
export const Pagination: TableFeature = {
|
|
62
|
-
getInitialState: (
|
|
62
|
+
getInitialState: (state): PaginationTableState => {
|
|
63
63
|
return {
|
|
64
|
+
...state,
|
|
64
65
|
pagination: {
|
|
65
66
|
pageCount: -1,
|
|
66
67
|
pageIndex: 0,
|
|
67
68
|
pageSize: 10,
|
|
68
|
-
...
|
|
69
|
+
...state?.pagination,
|
|
69
70
|
},
|
|
70
71
|
}
|
|
71
72
|
},
|
package/src/features/Pinning.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
TableGenerics,
|
|
7
7
|
Row,
|
|
8
8
|
Cell,
|
|
9
|
+
TableFeature,
|
|
9
10
|
} from '../types'
|
|
10
11
|
import { makeStateUpdater, memo } from '../utils'
|
|
11
12
|
|
|
@@ -31,7 +32,6 @@ export type ColumnPinningDefaultOptions = {
|
|
|
31
32
|
|
|
32
33
|
export type ColumnPinningColumnDef = {
|
|
33
34
|
enablePinning?: boolean
|
|
34
|
-
defaultCanPin?: boolean
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export type ColumnPinningColumn = {
|
|
@@ -47,12 +47,6 @@ export type ColumnPinningRow<TGenerics extends TableGenerics> = {
|
|
|
47
47
|
getRightVisibleCells: () => Cell<TGenerics>[]
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export type ColumnPinningCell<TGenerics extends TableGenerics> = {
|
|
51
|
-
getLeftVisibleCells: () => Cell<TGenerics>[]
|
|
52
|
-
getCenterVisibleCells: () => Cell<TGenerics>[]
|
|
53
|
-
getRightVisibleCells: () => Cell<TGenerics>[]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
50
|
export type ColumnPinningInstance<TGenerics extends TableGenerics> = {
|
|
57
51
|
setColumnPinning: (updater: Updater<ColumnPinningState>) => void
|
|
58
52
|
resetColumnPinning: () => void
|
|
@@ -68,13 +62,14 @@ export type ColumnPinningInstance<TGenerics extends TableGenerics> = {
|
|
|
68
62
|
|
|
69
63
|
//
|
|
70
64
|
|
|
71
|
-
export const Pinning = {
|
|
72
|
-
getInitialState: (): ColumnPinningTableState => {
|
|
65
|
+
export const Pinning: TableFeature = {
|
|
66
|
+
getInitialState: (state): ColumnPinningTableState => {
|
|
73
67
|
return {
|
|
74
68
|
columnPinning: {
|
|
75
69
|
left: [],
|
|
76
70
|
right: [],
|
|
77
71
|
},
|
|
72
|
+
...state,
|
|
78
73
|
}
|
|
79
74
|
},
|
|
80
75
|
|
|
@@ -159,67 +154,6 @@ export const Pinning = {
|
|
|
159
154
|
}
|
|
160
155
|
},
|
|
161
156
|
|
|
162
|
-
createCell: <TGenerics extends TableGenerics>(
|
|
163
|
-
cell: Cell<TGenerics>,
|
|
164
|
-
instance: TableInstance<TGenerics>
|
|
165
|
-
): ColumnPinningCell<TGenerics> => {
|
|
166
|
-
return {
|
|
167
|
-
getCenterVisibleCells: memo(
|
|
168
|
-
() => [
|
|
169
|
-
cell.row._getAllVisibleCells(),
|
|
170
|
-
instance.getState().columnPinning.left,
|
|
171
|
-
instance.getState().columnPinning.right,
|
|
172
|
-
],
|
|
173
|
-
(allCells, left, right) => {
|
|
174
|
-
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
|
|
175
|
-
|
|
176
|
-
return allCells.filter(d => !leftAndRight.includes(d.columnId))
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
key: 'row.getCenterVisibleCells',
|
|
180
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
181
|
-
}
|
|
182
|
-
),
|
|
183
|
-
getLeftVisibleCells: memo(
|
|
184
|
-
() => [
|
|
185
|
-
cell.row._getAllVisibleCells(),
|
|
186
|
-
instance.getState().columnPinning.left,
|
|
187
|
-
,
|
|
188
|
-
],
|
|
189
|
-
(allCells, left) => {
|
|
190
|
-
const cells = (left ?? [])
|
|
191
|
-
.map(columnId => allCells.find(cell => cell.columnId === columnId)!)
|
|
192
|
-
.filter(Boolean)
|
|
193
|
-
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>))
|
|
194
|
-
|
|
195
|
-
return cells
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
key: 'row.getLeftVisibleCells',
|
|
199
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
200
|
-
}
|
|
201
|
-
),
|
|
202
|
-
getRightVisibleCells: memo(
|
|
203
|
-
() => [
|
|
204
|
-
cell.row._getAllVisibleCells(),
|
|
205
|
-
instance.getState().columnPinning.right,
|
|
206
|
-
],
|
|
207
|
-
(allCells, right) => {
|
|
208
|
-
const cells = (right ?? [])
|
|
209
|
-
.map(columnId => allCells.find(cell => cell.columnId === columnId)!)
|
|
210
|
-
.filter(Boolean)
|
|
211
|
-
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>))
|
|
212
|
-
|
|
213
|
-
return cells
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
key: 'row.getRightVisibleCells',
|
|
217
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
218
|
-
}
|
|
219
|
-
),
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
|
|
223
157
|
createInstance: <TGenerics extends TableGenerics>(
|
|
224
158
|
instance: TableInstance<TGenerics>
|
|
225
159
|
): ColumnPinningInstance<TGenerics> => {
|
|
@@ -277,10 +211,8 @@ export const Pinning = {
|
|
|
277
211
|
|
|
278
212
|
return leafColumns.some(
|
|
279
213
|
d =>
|
|
280
|
-
d.enablePinning ??
|
|
281
|
-
instance.options.enablePinning ??
|
|
282
|
-
d.defaultCanPin ??
|
|
283
|
-
!!d.accessorFn
|
|
214
|
+
(d.enablePinning ?? true) &&
|
|
215
|
+
(instance.options.enablePinning ?? true)
|
|
284
216
|
)
|
|
285
217
|
},
|
|
286
218
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Row,
|
|
6
6
|
RowModel,
|
|
7
7
|
Updater,
|
|
8
|
+
TableFeature,
|
|
8
9
|
} from '../types'
|
|
9
10
|
import { makeStateUpdater, memo } from '../utils'
|
|
10
11
|
|
|
@@ -15,10 +16,10 @@ export type RowSelectionTableState = {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export type RowSelectionOptions<TGenerics extends TableGenerics> = {
|
|
18
|
-
onRowSelectionChange?: OnChangeFn<RowSelectionState>
|
|
19
19
|
enableRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
|
|
20
20
|
enableMultiRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
|
|
21
21
|
enableSubRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
|
|
22
|
+
onRowSelectionChange?: OnChangeFn<RowSelectionState>
|
|
22
23
|
// enableGroupingRowSelection?:
|
|
23
24
|
// | boolean
|
|
24
25
|
// | ((
|
|
@@ -76,10 +77,11 @@ export type RowSelectionInstance<TGenerics extends TableGenerics> = {
|
|
|
76
77
|
|
|
77
78
|
//
|
|
78
79
|
|
|
79
|
-
export const RowSelection = {
|
|
80
|
-
getInitialState: (): RowSelectionTableState => {
|
|
80
|
+
export const RowSelection: TableFeature = {
|
|
81
|
+
getInitialState: (state): RowSelectionTableState => {
|
|
81
82
|
return {
|
|
82
83
|
rowSelection: {},
|
|
84
|
+
...state,
|
|
83
85
|
}
|
|
84
86
|
},
|
|
85
87
|
|
package/src/features/Sorting.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
TableInstance,
|
|
13
13
|
Row,
|
|
14
14
|
Updater,
|
|
15
|
+
TableFeature,
|
|
15
16
|
} from '../types'
|
|
16
17
|
|
|
17
18
|
import { isFunction, makeStateUpdater, Overwrite } from '../utils'
|
|
@@ -108,18 +109,19 @@ export type SortingInstance<TGenerics extends TableGenerics> = {
|
|
|
108
109
|
|
|
109
110
|
//
|
|
110
111
|
|
|
111
|
-
export const Sorting = {
|
|
112
|
-
|
|
113
|
-
TGenerics extends TableGenerics
|
|
114
|
-
>(): SortingColumnDef<TGenerics> => {
|
|
112
|
+
export const Sorting: TableFeature = {
|
|
113
|
+
getInitialState: (state): SortingTableState => {
|
|
115
114
|
return {
|
|
116
|
-
|
|
115
|
+
sorting: [],
|
|
116
|
+
...state,
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
getDefaultColumn: <
|
|
121
|
+
TGenerics extends TableGenerics
|
|
122
|
+
>(): SortingColumnDef<TGenerics> => {
|
|
121
123
|
return {
|
|
122
|
-
|
|
124
|
+
sortingFn: 'auto',
|
|
123
125
|
}
|
|
124
126
|
},
|
|
125
127
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
TableInstance,
|
|
7
7
|
Updater,
|
|
8
8
|
Row,
|
|
9
|
+
TableFeature,
|
|
9
10
|
} from '../types'
|
|
10
11
|
import { makeStateUpdater, memo } from '../utils'
|
|
11
12
|
|
|
@@ -62,10 +63,11 @@ export type VisibilityColumn = {
|
|
|
62
63
|
|
|
63
64
|
//
|
|
64
65
|
|
|
65
|
-
export const Visibility = {
|
|
66
|
-
getInitialState: (): VisibilityTableState => {
|
|
66
|
+
export const Visibility: TableFeature = {
|
|
67
|
+
getInitialState: (state): VisibilityTableState => {
|
|
67
68
|
return {
|
|
68
69
|
columnVisibility: {},
|
|
70
|
+
...state,
|
|
69
71
|
}
|
|
70
72
|
},
|
|
71
73
|
|