@tanstack/table-core 8.0.0-alpha.64 → 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 +1 -0
- 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/Columns.js +7 -7
- package/build/cjs/features/Columns.js.map +1 -1
- package/build/cjs/features/Filters.js +153 -77
- package/build/cjs/features/Filters.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 +1 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +1 -1
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +6 -6
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +5 -5
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +3 -3
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +2 -2
- 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 +4 -4
- 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 +422 -446
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +363 -395
- package/build/types/features/Filters.d.ts +24 -15
- 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 +424 -447
- 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 +1 -0
- package/src/features/Cells.ts +3 -1
- package/src/features/Columns.ts +11 -7
- package/src/features/Filters.ts +202 -94
- package/src/features/Headers.ts +16 -16
- package/src/features/Ordering.ts +1 -1
- package/src/features/Pagination.ts +1 -1
- package/src/features/Pinning.ts +10 -6
- package/src/features/RowSelection.ts +9 -6
- package/src/features/Sorting.ts +3 -5
- package/src/features/Visibility.ts +3 -2
- 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
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { TableInstance, RowModel, TableGenerics, Row } from '../types'
|
|
2
|
-
import { memo } from '../utils'
|
|
3
|
-
import {
|
|
4
|
-
filterRowModelFromLeafs,
|
|
5
|
-
filterRowModelFromRoot,
|
|
6
|
-
} from './filterRowsUtils'
|
|
7
|
-
|
|
8
|
-
export function getColumnFilteredRowModelSync<
|
|
9
|
-
TGenerics extends TableGenerics
|
|
10
|
-
>(): (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics> {
|
|
11
|
-
return instance =>
|
|
12
|
-
memo(
|
|
13
|
-
() => [
|
|
14
|
-
instance.getState().columnFilters,
|
|
15
|
-
instance.getPreColumnFilteredRowModel(),
|
|
16
|
-
],
|
|
17
|
-
(columnFilters, rowModel) => {
|
|
18
|
-
const columnFilteredRowModel: RowModel<TGenerics> = (() => {
|
|
19
|
-
if (!rowModel.rows.length || !columnFilters?.length) {
|
|
20
|
-
return rowModel
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const filterFromLeafRows = instance.options.filterFromLeafRows
|
|
24
|
-
|
|
25
|
-
const filterRows = (
|
|
26
|
-
rowsToFilter: Row<TGenerics>[],
|
|
27
|
-
depth: number
|
|
28
|
-
) => {
|
|
29
|
-
for (let i = 0; i < columnFilters.length; i++) {
|
|
30
|
-
const { id: columnId, value: filterValue } = columnFilters[i]
|
|
31
|
-
// Find the columnFilters column
|
|
32
|
-
const column = instance.getColumn(columnId)
|
|
33
|
-
|
|
34
|
-
if (!column) {
|
|
35
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
36
|
-
console.warn(
|
|
37
|
-
`Table: Could not find a column with id: ${columnId}`
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
throw new Error()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (depth === 0) {
|
|
44
|
-
const preFilteredRows = [...rowsToFilter]
|
|
45
|
-
column.getPreFilteredRows = () => preFilteredRows
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const filterFn = instance.getColumnFilterFn(column.id)
|
|
49
|
-
|
|
50
|
-
if (!filterFn) {
|
|
51
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
52
|
-
console.warn(
|
|
53
|
-
`Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
continue
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Pass the rows, id, filterValue and column to the filterFn
|
|
60
|
-
// to get the filtered rows back
|
|
61
|
-
rowsToFilter = filterFn(rowsToFilter, [columnId], filterValue)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return rowsToFilter
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (filterFromLeafRows) {
|
|
68
|
-
return filterRowModelFromLeafs(rowModel.rows, filterRows, instance)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return filterRowModelFromRoot(rowModel.rows, filterRows, instance)
|
|
72
|
-
})()
|
|
73
|
-
|
|
74
|
-
// Now that each filtered column has it's partially filtered rows,
|
|
75
|
-
// lets assign the final filtered rows to all of the other columns
|
|
76
|
-
const nonFilteredColumns = instance
|
|
77
|
-
.getAllLeafColumns()
|
|
78
|
-
.filter(
|
|
79
|
-
column =>
|
|
80
|
-
!instance.getState().columnFilters?.find(d => d.id === column.id)
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
// This essentially enables faceted filter options to be built easily
|
|
84
|
-
// using every column's preFilteredRows value
|
|
85
|
-
|
|
86
|
-
nonFilteredColumns.forEach(column => {
|
|
87
|
-
column.getPreFilteredRows = () => columnFilteredRowModel.rows
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
return columnFilteredRowModel
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
key: 'getColumnFilteredRowModelSync',
|
|
94
|
-
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
95
|
-
onChange: () => {
|
|
96
|
-
instance.queue(() => {
|
|
97
|
-
instance._autoResetPageIndex()
|
|
98
|
-
})
|
|
99
|
-
},
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { TableInstance, RowModel, TableGenerics } from '../types'
|
|
2
|
-
import { incrementalMemo } from '../utils'
|
|
3
|
-
|
|
4
|
-
export function getGlobalFilteredRowModelAsync<
|
|
5
|
-
TGenerics extends TableGenerics
|
|
6
|
-
>(opts?: {
|
|
7
|
-
initialSync?: boolean
|
|
8
|
-
}): (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics> {
|
|
9
|
-
return instance =>
|
|
10
|
-
incrementalMemo(
|
|
11
|
-
() => [
|
|
12
|
-
instance.getState().globalFilter,
|
|
13
|
-
instance.getPreGlobalFilteredRowModel(),
|
|
14
|
-
],
|
|
15
|
-
(_globalFilter, rowModel): RowModel<TGenerics> => {
|
|
16
|
-
return {
|
|
17
|
-
rows: rowModel.rows.slice(),
|
|
18
|
-
flatRows: [],
|
|
19
|
-
rowsById: rowModel.rowsById,
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
(globalFilter, rowModel) => rowModelRef => scheduleTask => {
|
|
23
|
-
// TODO: Figure out how to do scheduled filtering
|
|
24
|
-
// The trick will be batching those tasks in a way
|
|
25
|
-
// that makes them fast. JS work loops don't tend to do well with
|
|
26
|
-
// a high number of tasks that do one thing. Instead, shoot for each
|
|
27
|
-
// task to have a few thousand opts (or whatever amount is generally
|
|
28
|
-
// fast for most devices).
|
|
29
|
-
throw new Error('')
|
|
30
|
-
|
|
31
|
-
// const globalFilteredRowModel: RowModel<TGenerics> = (() => {
|
|
32
|
-
// if (!rowModel.rows.length || !globalFilter) {
|
|
33
|
-
// return rowModel
|
|
34
|
-
// }
|
|
35
|
-
|
|
36
|
-
// const filterFromLeafRows = instance.options.filterFromLeafRows
|
|
37
|
-
|
|
38
|
-
// const filterFn = instance.getGlobalFilterFn()
|
|
39
|
-
|
|
40
|
-
// if (!filterFn) {
|
|
41
|
-
// if (process.env.NODE_ENV !== 'production') {
|
|
42
|
-
// console.warn(`Could not find a valid 'globalFilterType'`)
|
|
43
|
-
// }
|
|
44
|
-
// return rowModel
|
|
45
|
-
// }
|
|
46
|
-
|
|
47
|
-
// const filterableColumns = instance
|
|
48
|
-
// .getAllLeafColumns()
|
|
49
|
-
// .filter(column => column.getCanGlobalFilter())
|
|
50
|
-
|
|
51
|
-
// const filterableColumnIds = filterableColumns.map(d => d.id)
|
|
52
|
-
|
|
53
|
-
// const filterRows = (rows: Row<TGenerics>[]) => {
|
|
54
|
-
// return filterFn(rows, filterableColumnIds, globalFilter)
|
|
55
|
-
// }
|
|
56
|
-
|
|
57
|
-
// if (filterFromLeafRows) {
|
|
58
|
-
// return filterRowModelFromLeafs(rowModel.rows, filterRows, instance)
|
|
59
|
-
// }
|
|
60
|
-
|
|
61
|
-
// return filterRowModelFromRoot(rowModel.rows, filterRows, instance)
|
|
62
|
-
// })()
|
|
63
|
-
|
|
64
|
-
// // Now that each filtered column has it's partially filtered rows,
|
|
65
|
-
// // lets assign the final filtered rows to all of the other columns
|
|
66
|
-
// const nonFilteredColumns = instance
|
|
67
|
-
// .getAllLeafColumns()
|
|
68
|
-
// .filter(
|
|
69
|
-
// column =>
|
|
70
|
-
// !instance.getState().columnFilters?.find(d => d.id === column.id)
|
|
71
|
-
// )
|
|
72
|
-
|
|
73
|
-
// // This essentially enables faceted filter options to be built easily
|
|
74
|
-
// // using every column's preFilteredRows value
|
|
75
|
-
|
|
76
|
-
// nonFilteredColumns.forEach(column => {
|
|
77
|
-
// column.getPreFilteredRows = () => globalFilteredRowModel.rows
|
|
78
|
-
// })
|
|
79
|
-
|
|
80
|
-
// return globalFilteredRowModel
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
key: 'getGlobalFilteredRowModelAsync',
|
|
84
|
-
initialSync: opts?.initialSync,
|
|
85
|
-
onProgress: progress => {
|
|
86
|
-
instance.setState(old => ({ ...old, globalFilterProgress: progress }))
|
|
87
|
-
},
|
|
88
|
-
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
89
|
-
onChange: () => {
|
|
90
|
-
instance.queue(() => {
|
|
91
|
-
instance._autoResetPageIndex()
|
|
92
|
-
})
|
|
93
|
-
},
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { TableInstance, RowModel, TableGenerics, Row } from '../types'
|
|
2
|
-
import { memo } from '../utils'
|
|
3
|
-
import {
|
|
4
|
-
filterRowModelFromLeafs,
|
|
5
|
-
filterRowModelFromRoot,
|
|
6
|
-
} from './filterRowsUtils'
|
|
7
|
-
|
|
8
|
-
export function getGlobalFilteredRowModelSync<
|
|
9
|
-
TGenerics extends TableGenerics
|
|
10
|
-
>(): (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics> {
|
|
11
|
-
return instance =>
|
|
12
|
-
memo(
|
|
13
|
-
() => [
|
|
14
|
-
instance.getState().globalFilter,
|
|
15
|
-
instance.getPreGlobalFilteredRowModel(),
|
|
16
|
-
],
|
|
17
|
-
(globalFilter, rowModel) => {
|
|
18
|
-
const globalFilteredRowModel: RowModel<TGenerics> = (() => {
|
|
19
|
-
if (!rowModel.rows.length || !globalFilter) {
|
|
20
|
-
return rowModel
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const filterFromLeafRows = instance.options.filterFromLeafRows
|
|
24
|
-
|
|
25
|
-
const filterFn = instance.getGlobalFilterFn()
|
|
26
|
-
|
|
27
|
-
if (!filterFn) {
|
|
28
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
29
|
-
console.warn(`Could not find a valid 'globalFilterType'`)
|
|
30
|
-
}
|
|
31
|
-
return rowModel
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const filterableColumns = instance
|
|
35
|
-
.getAllLeafColumns()
|
|
36
|
-
.filter(column => column.getCanGlobalFilter())
|
|
37
|
-
|
|
38
|
-
const filterableColumnIds = filterableColumns.map(d => d.id)
|
|
39
|
-
|
|
40
|
-
const filterRows = (rows: Row<TGenerics>[]) => {
|
|
41
|
-
return filterFn(rows, filterableColumnIds, globalFilter)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (filterFromLeafRows) {
|
|
45
|
-
return filterRowModelFromLeafs(rowModel.rows, filterRows, instance)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return filterRowModelFromRoot(rowModel.rows, filterRows, instance)
|
|
49
|
-
})()
|
|
50
|
-
|
|
51
|
-
// Now that each filtered column has it's partially filtered rows,
|
|
52
|
-
// lets assign the final filtered rows to all of the other columns
|
|
53
|
-
const nonFilteredColumns = instance
|
|
54
|
-
.getAllLeafColumns()
|
|
55
|
-
.filter(
|
|
56
|
-
column =>
|
|
57
|
-
!instance.getState().columnFilters?.find(d => d.id === column.id)
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
// This essentially enables faceted filter options to be built easily
|
|
61
|
-
// using every column's preFilteredRows value
|
|
62
|
-
|
|
63
|
-
nonFilteredColumns.forEach(column => {
|
|
64
|
-
column.getPreFilteredRows = () => globalFilteredRowModel.rows
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
return globalFilteredRowModel
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
key: 'getGlobalFilteredRowModelSync',
|
|
71
|
-
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
72
|
-
onChange: () => {
|
|
73
|
-
instance.queue(() => {
|
|
74
|
-
instance._autoResetPageIndex()
|
|
75
|
-
})
|
|
76
|
-
},
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
}
|