@tanstack/table-core 8.0.0-alpha.62 → 8.0.0-alpha.65
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 +8 -5
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/features/Cells.js +1 -1
- package/build/cjs/features/Cells.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/Columns.js +7 -7
- package/build/cjs/features/Columns.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 +158 -80
- 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/Headers.js +16 -16
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +6 -5
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +5 -5
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +17 -78
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +8 -8
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +8 -8
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +5 -5
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterFns.js +51 -108
- package/build/cjs/filterFns.js.map +1 -1
- package/build/cjs/index.js +5 -4
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +21 -0
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getCoreRowModelAsync.js +1 -1
- package/build/cjs/utils/getCoreRowModelAsync.js.map +1 -1
- package/build/cjs/utils/getCoreRowModelSync.js +1 -1
- package/build/cjs/utils/getCoreRowModelSync.js.map +1 -1
- package/build/cjs/utils/getExpandedRowModel.js +1 -1
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getFilteredRowModelSync.js +130 -0
- package/build/cjs/utils/getFilteredRowModelSync.js.map +1 -0
- package/build/cjs/utils/getGroupedRowModel.js +1 -1
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +1 -1
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/cjs/utils/getSortedRowModelSync.js +1 -1
- package/build/cjs/utils/getSortedRowModelSync.js.map +1 -1
- package/build/cjs/utils.js +2 -6
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +491 -573
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +388 -402
- package/build/types/features/Expanding.d.ts +2 -7
- package/build/types/features/Filters.d.ts +27 -29
- 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/types/filterFns.d.ts +10 -52
- package/build/types/index.d.ts +1 -2
- package/build/types/types.d.ts +2 -2
- package/build/types/utils/filterRowsUtils.d.ts +1 -0
- package/build/types/utils/{getColumnFilteredRowModelAsync.d.ts → getFilteredRowModelAsync.d.ts} +1 -1
- package/build/types/utils/getFilteredRowModelSync.d.ts +2 -0
- package/build/types/utils.d.ts +2 -2
- package/build/umd/index.development.js +494 -574
- 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 +2 -1
- package/src/core.ts +6 -5
- package/src/features/Cells.ts +3 -1
- package/src/features/ColumnSizing.ts +2 -1
- package/src/features/Columns.ts +11 -7
- package/src/features/Expanding.ts +4 -2
- package/src/features/Filters.ts +216 -116
- package/src/features/Grouping.ts +23 -21
- package/src/features/Headers.ts +16 -16
- package/src/features/Ordering.ts +7 -9
- package/src/features/Pagination.ts +4 -3
- package/src/features/Pinning.ts +16 -80
- package/src/features/RowSelection.ts +14 -9
- package/src/features/Sorting.ts +12 -12
- package/src/features/Visibility.ts +7 -4
- package/src/filterFns.ts +74 -147
- package/src/index.ts +1 -2
- package/src/types.ts +2 -0
- package/src/utils/filterRowsUtils.ts +24 -0
- package/src/utils/getCoreRowModelAsync.ts +1 -1
- package/src/utils/getCoreRowModelSync.ts +1 -1
- package/src/utils/getExpandedRowModel.ts +1 -1
- package/src/utils/getFilteredRowModelAsync.ts +49 -0
- package/src/utils/getFilteredRowModelSync.ts +150 -0
- package/src/utils/getGroupedRowModel.ts +1 -1
- package/src/utils/getPaginationRowModel.ts +1 -1
- package/src/utils/getSortedRowModelAsync.ts +1 -1
- package/src/utils/getSortedRowModelSync.ts +1 -1
- package/src/utils.ts +2 -4
- package/build/cjs/utils/getColumnFilteredRowModelSync.js +0 -115
- package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +0 -1
- package/build/cjs/utils/getGlobalFilteredRowModelSync.js +0 -91
- package/build/cjs/utils/getGlobalFilteredRowModelSync.js.map +0 -1
- package/build/types/utils/getColumnFilteredRowModelSync.d.ts +0 -2
- package/build/types/utils/getGlobalFilteredRowModelAsync.d.ts +0 -4
- package/build/types/utils/getGlobalFilteredRowModelSync.d.ts +0 -2
- package/src/utils/getColumnFilteredRowModelAsync.ts +0 -118
- package/src/utils/getColumnFilteredRowModelSync.ts +0 -102
- package/src/utils/getGlobalFilteredRowModelAsync.ts +0 -96
- package/src/utils/getGlobalFilteredRowModelSync.ts +0 -79
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/Headers.ts
CHANGED
|
@@ -163,7 +163,7 @@ export const Headers = {
|
|
|
163
163
|
return headerGroups
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
|
-
key: 'getHeaderGroups',
|
|
166
|
+
key: process.env.NODE_ENV === 'production' && 'getHeaderGroups',
|
|
167
167
|
debug: () =>
|
|
168
168
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
169
169
|
}
|
|
@@ -183,7 +183,7 @@ export const Headers = {
|
|
|
183
183
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'center')
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
|
-
key: 'getCenterHeaderGroups',
|
|
186
|
+
key: process.env.NODE_ENV === 'production' && 'getCenterHeaderGroups',
|
|
187
187
|
debug: () =>
|
|
188
188
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
189
189
|
}
|
|
@@ -200,7 +200,7 @@ export const Headers = {
|
|
|
200
200
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'left')
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
|
-
key: 'getLeftHeaderGroups',
|
|
203
|
+
key: process.env.NODE_ENV === 'production' && 'getLeftHeaderGroups',
|
|
204
204
|
debug: () =>
|
|
205
205
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
206
206
|
}
|
|
@@ -217,7 +217,7 @@ export const Headers = {
|
|
|
217
217
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'right')
|
|
218
218
|
},
|
|
219
219
|
{
|
|
220
|
-
key: 'getRightHeaderGroups',
|
|
220
|
+
key: process.env.NODE_ENV === 'production' && 'getRightHeaderGroups',
|
|
221
221
|
debug: () =>
|
|
222
222
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
223
223
|
}
|
|
@@ -231,7 +231,7 @@ export const Headers = {
|
|
|
231
231
|
return [...headerGroups].reverse()
|
|
232
232
|
},
|
|
233
233
|
{
|
|
234
|
-
key: 'getFooterGroups',
|
|
234
|
+
key: process.env.NODE_ENV === 'production' && 'getFooterGroups',
|
|
235
235
|
debug: () =>
|
|
236
236
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
237
237
|
}
|
|
@@ -243,7 +243,7 @@ export const Headers = {
|
|
|
243
243
|
return [...headerGroups].reverse()
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
|
-
key: 'getLeftFooterGroups',
|
|
246
|
+
key: process.env.NODE_ENV === 'production' && 'getLeftFooterGroups',
|
|
247
247
|
debug: () =>
|
|
248
248
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
249
249
|
}
|
|
@@ -255,7 +255,7 @@ export const Headers = {
|
|
|
255
255
|
return [...headerGroups].reverse()
|
|
256
256
|
},
|
|
257
257
|
{
|
|
258
|
-
key: 'getCenterFooterGroups',
|
|
258
|
+
key: process.env.NODE_ENV === 'production' && 'getCenterFooterGroups',
|
|
259
259
|
debug: () =>
|
|
260
260
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
261
261
|
}
|
|
@@ -267,7 +267,7 @@ export const Headers = {
|
|
|
267
267
|
return [...headerGroups].reverse()
|
|
268
268
|
},
|
|
269
269
|
{
|
|
270
|
-
key: 'getRightFooterGroups',
|
|
270
|
+
key: process.env.NODE_ENV === 'production' && 'getRightFooterGroups',
|
|
271
271
|
debug: () =>
|
|
272
272
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
273
273
|
}
|
|
@@ -285,7 +285,7 @@ export const Headers = {
|
|
|
285
285
|
.flat()
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
|
-
key: 'getFlatHeaders',
|
|
288
|
+
key: process.env.NODE_ENV === 'production' && 'getFlatHeaders',
|
|
289
289
|
debug: () =>
|
|
290
290
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
291
291
|
}
|
|
@@ -301,7 +301,7 @@ export const Headers = {
|
|
|
301
301
|
.flat()
|
|
302
302
|
},
|
|
303
303
|
{
|
|
304
|
-
key: 'getLeftFlatHeaders',
|
|
304
|
+
key: process.env.NODE_ENV === 'production' && 'getLeftFlatHeaders',
|
|
305
305
|
debug: () =>
|
|
306
306
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
307
307
|
}
|
|
@@ -317,7 +317,7 @@ export const Headers = {
|
|
|
317
317
|
.flat()
|
|
318
318
|
},
|
|
319
319
|
{
|
|
320
|
-
key: 'getCenterFlatHeaders',
|
|
320
|
+
key: process.env.NODE_ENV === 'production' && 'getCenterFlatHeaders',
|
|
321
321
|
debug: () =>
|
|
322
322
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
323
323
|
}
|
|
@@ -333,7 +333,7 @@ export const Headers = {
|
|
|
333
333
|
.flat()
|
|
334
334
|
},
|
|
335
335
|
{
|
|
336
|
-
key: 'getRightFlatHeaders',
|
|
336
|
+
key: process.env.NODE_ENV === 'production' && 'getRightFlatHeaders',
|
|
337
337
|
debug: () =>
|
|
338
338
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
339
339
|
}
|
|
@@ -347,7 +347,7 @@ export const Headers = {
|
|
|
347
347
|
return flatHeaders.filter(header => !header.subHeaders?.length)
|
|
348
348
|
},
|
|
349
349
|
{
|
|
350
|
-
key: 'getCenterLeafHeaders',
|
|
350
|
+
key: process.env.NODE_ENV === 'production' && 'getCenterLeafHeaders',
|
|
351
351
|
debug: () =>
|
|
352
352
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
353
353
|
}
|
|
@@ -359,7 +359,7 @@ export const Headers = {
|
|
|
359
359
|
return flatHeaders.filter(header => !header.subHeaders?.length)
|
|
360
360
|
},
|
|
361
361
|
{
|
|
362
|
-
key: 'getLeftLeafHeaders',
|
|
362
|
+
key: process.env.NODE_ENV === 'production' && 'getLeftLeafHeaders',
|
|
363
363
|
debug: () =>
|
|
364
364
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
365
365
|
}
|
|
@@ -371,7 +371,7 @@ export const Headers = {
|
|
|
371
371
|
return flatHeaders.filter(header => !header.subHeaders?.length)
|
|
372
372
|
},
|
|
373
373
|
{
|
|
374
|
-
key: 'getRightLeafHeaders',
|
|
374
|
+
key: process.env.NODE_ENV === 'production' && 'getRightLeafHeaders',
|
|
375
375
|
debug: () =>
|
|
376
376
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
377
377
|
}
|
|
@@ -395,7 +395,7 @@ export const Headers = {
|
|
|
395
395
|
.flat()
|
|
396
396
|
},
|
|
397
397
|
{
|
|
398
|
-
key: 'getLeafHeaders',
|
|
398
|
+
key: process.env.NODE_ENV === 'production' && 'getLeafHeaders',
|
|
399
399
|
debug: () =>
|
|
400
400
|
instance.options.debugAll ?? instance.options.debugHeaders,
|
|
401
401
|
}
|
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,14 +97,10 @@ 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
|
-
key: 'getOrderColumnsFn',
|
|
103
|
+
key: process.env.NODE_ENV === 'production' && 'getOrderColumnsFn',
|
|
106
104
|
// debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
107
105
|
}
|
|
108
106
|
),
|
|
@@ -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
|
},
|
|
@@ -183,7 +184,7 @@ export const Pagination: TableFeature = {
|
|
|
183
184
|
return pageOptions
|
|
184
185
|
},
|
|
185
186
|
{
|
|
186
|
-
key: 'getPageOptions',
|
|
187
|
+
key: process.env.NODE_ENV === 'production' && 'getPageOptions',
|
|
187
188
|
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
188
189
|
}
|
|
189
190
|
),
|
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
|
|
|
@@ -115,7 +110,9 @@ export const Pinning = {
|
|
|
115
110
|
return allCells.filter(d => !leftAndRight.includes(d.columnId))
|
|
116
111
|
},
|
|
117
112
|
{
|
|
118
|
-
key:
|
|
113
|
+
key:
|
|
114
|
+
process.env.NODE_ENV === 'production' &&
|
|
115
|
+
'row.getCenterVisibleCells',
|
|
119
116
|
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
120
117
|
}
|
|
121
118
|
),
|
|
@@ -134,7 +131,8 @@ export const Pinning = {
|
|
|
134
131
|
return cells
|
|
135
132
|
},
|
|
136
133
|
{
|
|
137
|
-
key:
|
|
134
|
+
key:
|
|
135
|
+
process.env.NODE_ENV === 'production' && 'row.getLeftVisibleCells',
|
|
138
136
|
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
139
137
|
}
|
|
140
138
|
),
|
|
@@ -152,68 +150,8 @@ export const Pinning = {
|
|
|
152
150
|
return cells
|
|
153
151
|
},
|
|
154
152
|
{
|
|
155
|
-
key:
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
|
|
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',
|
|
153
|
+
key:
|
|
154
|
+
process.env.NODE_ENV === 'production' && 'row.getRightVisibleCells',
|
|
217
155
|
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
218
156
|
}
|
|
219
157
|
),
|
|
@@ -277,10 +215,8 @@ export const Pinning = {
|
|
|
277
215
|
|
|
278
216
|
return leafColumns.some(
|
|
279
217
|
d =>
|
|
280
|
-
d.enablePinning ??
|
|
281
|
-
instance.options.enablePinning ??
|
|
282
|
-
d.defaultCanPin ??
|
|
283
|
-
!!d.accessorFn
|
|
218
|
+
(d.enablePinning ?? true) &&
|
|
219
|
+
(instance.options.enablePinning ?? true)
|
|
284
220
|
)
|
|
285
221
|
},
|
|
286
222
|
|
|
@@ -327,7 +263,7 @@ export const Pinning = {
|
|
|
327
263
|
.filter(Boolean)
|
|
328
264
|
},
|
|
329
265
|
{
|
|
330
|
-
key: 'getLeftLeafColumns',
|
|
266
|
+
key: process.env.NODE_ENV === 'production' && 'getLeftLeafColumns',
|
|
331
267
|
debug: () =>
|
|
332
268
|
instance.options.debugAll ?? instance.options.debugColumns,
|
|
333
269
|
}
|
|
@@ -344,7 +280,7 @@ export const Pinning = {
|
|
|
344
280
|
.filter(Boolean)
|
|
345
281
|
},
|
|
346
282
|
{
|
|
347
|
-
key: 'getRightLeafColumns',
|
|
283
|
+
key: process.env.NODE_ENV === 'production' && 'getRightLeafColumns',
|
|
348
284
|
debug: () =>
|
|
349
285
|
instance.options.debugAll ?? instance.options.debugColumns,
|
|
350
286
|
}
|
|
@@ -362,7 +298,7 @@ export const Pinning = {
|
|
|
362
298
|
return allColumns.filter(d => !leftAndRight.includes(d.id))
|
|
363
299
|
},
|
|
364
300
|
{
|
|
365
|
-
key: 'getCenterLeafColumns',
|
|
301
|
+
key: process.env.NODE_ENV === 'production' && 'getCenterLeafColumns',
|
|
366
302
|
debug: () =>
|
|
367
303
|
instance.options.debugAll ?? instance.options.debugColumns,
|
|
368
304
|
}
|
|
@@ -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
|
|
|
@@ -237,7 +239,7 @@ export const RowSelection = {
|
|
|
237
239
|
return selectRowsFn(instance, rowModel)
|
|
238
240
|
},
|
|
239
241
|
{
|
|
240
|
-
key: 'getSelectedRowModel',
|
|
242
|
+
key: process.env.NODE_ENV === 'production' && 'getSelectedRowModel',
|
|
241
243
|
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
242
244
|
}
|
|
243
245
|
),
|
|
@@ -245,7 +247,7 @@ export const RowSelection = {
|
|
|
245
247
|
getFilteredSelectedRowModel: memo(
|
|
246
248
|
() => [
|
|
247
249
|
instance.getState().rowSelection,
|
|
248
|
-
instance.
|
|
250
|
+
instance.getFilteredRowModel(),
|
|
249
251
|
],
|
|
250
252
|
(rowSelection, rowModel) => {
|
|
251
253
|
if (!Object.keys(rowSelection).length) {
|
|
@@ -259,7 +261,9 @@ export const RowSelection = {
|
|
|
259
261
|
return selectRowsFn(instance, rowModel)
|
|
260
262
|
},
|
|
261
263
|
{
|
|
262
|
-
key:
|
|
264
|
+
key:
|
|
265
|
+
process.env.NODE_ENV === 'production' &&
|
|
266
|
+
'getFilteredSelectedRowModel',
|
|
263
267
|
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
264
268
|
}
|
|
265
269
|
),
|
|
@@ -278,7 +282,9 @@ export const RowSelection = {
|
|
|
278
282
|
return selectRowsFn(instance, rowModel)
|
|
279
283
|
},
|
|
280
284
|
{
|
|
281
|
-
key:
|
|
285
|
+
key:
|
|
286
|
+
process.env.NODE_ENV === 'production' &&
|
|
287
|
+
'getGroupedSelectedRowModel',
|
|
282
288
|
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
283
289
|
}
|
|
284
290
|
),
|
|
@@ -364,8 +370,7 @@ export const RowSelection = {
|
|
|
364
370
|
// },
|
|
365
371
|
|
|
366
372
|
getIsAllRowsSelected: () => {
|
|
367
|
-
const preFilteredFlatRows =
|
|
368
|
-
instance.getPreGlobalFilteredRowModel().flatRows
|
|
373
|
+
const preFilteredFlatRows = instance.getPreFilteredRowModel().flatRows
|
|
369
374
|
const { rowSelection } = instance.getState()
|
|
370
375
|
|
|
371
376
|
let isAllRowsSelected = Boolean(
|
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
|
|
|
@@ -159,9 +161,7 @@ export const Sorting = {
|
|
|
159
161
|
|
|
160
162
|
return {
|
|
161
163
|
getColumnAutoSortingFn: columnId => {
|
|
162
|
-
const firstRows = instance
|
|
163
|
-
.getGlobalFilteredRowModel()
|
|
164
|
-
.flatRows.slice(100)
|
|
164
|
+
const firstRows = instance.getFilteredRowModel().flatRows.slice(100)
|
|
165
165
|
|
|
166
166
|
let isString = false
|
|
167
167
|
|
|
@@ -188,7 +188,7 @@ export const Sorting = {
|
|
|
188
188
|
return sortingFns.basic
|
|
189
189
|
},
|
|
190
190
|
getColumnAutoSortDir: columnId => {
|
|
191
|
-
const firstRow = instance.
|
|
191
|
+
const firstRow = instance.getFilteredRowModel().flatRows[0]
|
|
192
192
|
|
|
193
193
|
const value = firstRow?.values[columnId]
|
|
194
194
|
|
|
@@ -397,7 +397,7 @@ export const Sorting = {
|
|
|
397
397
|
}
|
|
398
398
|
},
|
|
399
399
|
|
|
400
|
-
getPreSortedRowModel: () => instance.
|
|
400
|
+
getPreSortedRowModel: () => instance.getFilteredRowModel(),
|
|
401
401
|
getSortedRowModel: () => {
|
|
402
402
|
if (
|
|
403
403
|
!instance._getSortedRowModel &&
|
|
@@ -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
|
|
|
@@ -119,7 +121,8 @@ export const Visibility = {
|
|
|
119
121
|
return row.getAllCells().filter(cell => cell.column.getIsVisible())
|
|
120
122
|
},
|
|
121
123
|
{
|
|
122
|
-
key:
|
|
124
|
+
key:
|
|
125
|
+
process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
123
126
|
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
124
127
|
}
|
|
125
128
|
),
|
|
@@ -131,7 +134,7 @@ export const Visibility = {
|
|
|
131
134
|
],
|
|
132
135
|
(left, center, right) => [...left, ...center, ...right],
|
|
133
136
|
{
|
|
134
|
-
key: 'row.getVisibleCells',
|
|
137
|
+
key: process.env.NODE_ENV === 'production' && 'row.getVisibleCells',
|
|
135
138
|
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
136
139
|
}
|
|
137
140
|
),
|