@tanstack/table-core 8.0.11 → 8.0.14
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/cell.js +13 -13
- package/build/cjs/core/cell.js.map +1 -1
- package/build/cjs/core/column.js +20 -21
- package/build/cjs/core/column.js.map +1 -1
- package/build/cjs/core/headers.js +63 -68
- package/build/cjs/core/headers.js.map +1 -1
- package/build/cjs/core/row.js +16 -11
- package/build/cjs/core/row.js.map +1 -1
- package/build/cjs/core/{instance.js → table.js} +46 -57
- package/build/cjs/core/table.js.map +1 -0
- package/build/cjs/features/ColumnSizing.js +36 -36
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +34 -34
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +46 -52
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +24 -49
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Ordering.js +8 -8
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +37 -37
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +33 -33
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +67 -67
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +36 -40
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +30 -30
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +2 -4
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +8 -8
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +8 -8
- package/build/cjs/utils/getCoreRowModel.js.map +1 -1
- package/build/cjs/utils/getExpandedRowModel.js +4 -4
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getFacetedMinMaxValues.js +3 -3
- package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -1
- package/build/cjs/utils/getFacetedRowModel.js +4 -4
- package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
- package/build/cjs/utils/getFacetedUniqueValues.js +3 -3
- package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -1
- package/build/cjs/utils/getFilteredRowModel.js +8 -8
- package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +9 -9
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +4 -4
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/cjs/utils/getSortedRowModel.js +7 -7
- package/build/cjs/utils/getSortedRowModel.js.map +1 -1
- package/build/cjs/utils.js +2 -2
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +567 -670
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +1092 -0
- package/build/types/index.d.ts +759 -0
- package/build/umd/index.development.js +567 -671
- 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 -2
- package/src/core/cell.ts +34 -28
- package/src/core/column.ts +83 -72
- package/src/core/headers.ts +118 -149
- package/src/core/row.ts +31 -25
- package/src/core/{instance.ts → table.ts} +85 -116
- package/src/features/ColumnSizing.ts +45 -47
- package/src/features/Expanding.ts +53 -59
- package/src/features/Filters.ts +112 -132
- package/src/features/Grouping.ts +63 -112
- package/src/features/Ordering.ts +19 -21
- package/src/features/Pagination.ts +54 -55
- package/src/features/Pinning.ts +49 -61
- package/src/features/RowSelection.ts +97 -108
- package/src/features/Sorting.ts +57 -72
- package/src/features/Visibility.ts +48 -48
- package/src/index.ts +1 -2
- package/src/types.ts +64 -69
- package/src/utils/filterRowsUtils.ts +33 -28
- package/src/utils/getCoreRowModel.ts +22 -22
- package/src/utils/getExpandedRowModel.ts +15 -15
- package/src/utils/getFacetedMinMaxValues.ts +6 -6
- package/src/utils/getFacetedRowModel.ts +12 -12
- package/src/utils/getFacetedUniqueValues.ts +6 -6
- package/src/utils/getFilteredRowModel.ts +17 -17
- package/src/utils/getGroupedRowModel.ts +18 -21
- package/src/utils/getPaginationRowModel.ts +10 -13
- package/src/utils/getSortedRowModel.ts +14 -14
- package/src/utils.ts +8 -2
- package/build/cjs/core/instance.js.map +0 -1
- package/build/cjs/createTable.js +0 -72
- package/build/cjs/createTable.js.map +0 -1
- package/src/createTable.ts +0 -188
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreOptions, CoreTableState, CoreInstance } from './core/
|
|
1
|
+
import { CoreOptions, CoreTableState, CoreInstance } from './core/table'
|
|
2
2
|
import { CoreColumn, CoreColumnDef } from './core/column'
|
|
3
3
|
import {
|
|
4
4
|
VisibilityInstance,
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
SortingTableState,
|
|
39
39
|
} from './features/Sorting'
|
|
40
40
|
import {
|
|
41
|
+
CustomAggregationFns,
|
|
41
42
|
GroupingCell,
|
|
42
43
|
GroupingColumn,
|
|
43
44
|
GroupingColumnDef,
|
|
@@ -79,51 +80,45 @@ import { CoreCell } from './core/cell'
|
|
|
79
80
|
export type Updater<T> = T | ((old: T) => T)
|
|
80
81
|
export type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void
|
|
81
82
|
|
|
83
|
+
export type RowData = object | any[]
|
|
84
|
+
|
|
82
85
|
export type TableGenerics = {
|
|
83
86
|
Row?: any
|
|
84
87
|
Value?: any
|
|
85
|
-
FilterFns?: any
|
|
86
|
-
SortingFns?: any
|
|
87
|
-
AggregationFns?: any
|
|
88
|
-
Renderer?: any
|
|
89
|
-
Rendered?: any
|
|
90
88
|
ColumnMeta?: any
|
|
91
89
|
TableMeta?: any
|
|
92
|
-
FilterMeta?: any
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
export type AnyRender = (Comp: any, props: any) => any
|
|
96
93
|
|
|
97
|
-
export type
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
PartialKeys<TableOptionsResolved<TGenerics>, 'state' | 'onStateChange'>,
|
|
126
|
-
'render' | 'renderFallbackValue'
|
|
94
|
+
export type Table<TData extends RowData> = CoreInstance<TData> &
|
|
95
|
+
HeadersInstance<TData> &
|
|
96
|
+
VisibilityInstance<TData> &
|
|
97
|
+
ColumnOrderInstance<TData> &
|
|
98
|
+
ColumnPinningInstance<TData> &
|
|
99
|
+
FiltersInstance<TData> &
|
|
100
|
+
SortingInstance<TData> &
|
|
101
|
+
GroupingInstance<TData> &
|
|
102
|
+
ColumnSizingInstance &
|
|
103
|
+
ExpandedInstance<TData> &
|
|
104
|
+
PaginationInstance<TData> &
|
|
105
|
+
RowSelectionInstance<TData>
|
|
106
|
+
|
|
107
|
+
export type TableOptionsResolved<TData extends RowData> = CoreOptions<TData> &
|
|
108
|
+
VisibilityOptions &
|
|
109
|
+
ColumnOrderOptions &
|
|
110
|
+
ColumnPinningOptions &
|
|
111
|
+
FiltersOptions<TData> &
|
|
112
|
+
SortingOptions<TData> &
|
|
113
|
+
GroupingOptions &
|
|
114
|
+
ExpandedOptions<TData> &
|
|
115
|
+
ColumnSizingOptions &
|
|
116
|
+
PaginationOptions &
|
|
117
|
+
RowSelectionOptions<TData>
|
|
118
|
+
|
|
119
|
+
export type TableOptions<TData extends RowData> = PartialKeys<
|
|
120
|
+
TableOptionsResolved<TData>,
|
|
121
|
+
'state' | 'onStateChange' | 'renderFallbackValue'
|
|
127
122
|
>
|
|
128
123
|
|
|
129
124
|
export type TableState = CoreTableState &
|
|
@@ -152,10 +147,10 @@ export type InitialTableState = Partial<
|
|
|
152
147
|
RowSelectionTableState
|
|
153
148
|
>
|
|
154
149
|
|
|
155
|
-
export type Row<
|
|
156
|
-
VisibilityRow<
|
|
157
|
-
ColumnPinningRow<
|
|
158
|
-
FiltersRow<
|
|
150
|
+
export type Row<TData extends RowData> = CoreRow<TData> &
|
|
151
|
+
VisibilityRow<TData> &
|
|
152
|
+
ColumnPinningRow<TData> &
|
|
153
|
+
FiltersRow<TData> &
|
|
159
154
|
GroupingRow &
|
|
160
155
|
RowSelectionRow &
|
|
161
156
|
ExpandedRow
|
|
@@ -164,42 +159,42 @@ export type RowValues = {
|
|
|
164
159
|
[key: string]: any
|
|
165
160
|
}
|
|
166
161
|
|
|
167
|
-
export type RowModel<
|
|
168
|
-
rows: Row<
|
|
169
|
-
flatRows: Row<
|
|
170
|
-
rowsById: Record<string, Row<
|
|
162
|
+
export type RowModel<TData extends RowData> = {
|
|
163
|
+
rows: Row<TData>[]
|
|
164
|
+
flatRows: Row<TData>[]
|
|
165
|
+
rowsById: Record<string, Row<TData>>
|
|
171
166
|
}
|
|
172
167
|
|
|
173
|
-
export type AccessorFn<TData> = (
|
|
168
|
+
export type AccessorFn<TData extends RowData> = (
|
|
169
|
+
originalRow: TData,
|
|
170
|
+
index: number
|
|
171
|
+
) => any
|
|
174
172
|
|
|
175
|
-
export type
|
|
173
|
+
export type ColumnDefTemplate<TProps extends object> =
|
|
176
174
|
| string
|
|
177
|
-
| ((props: TProps) =>
|
|
178
|
-
|
|
179
|
-
export type ColumnDef<
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
export type Column<TGenerics extends TableGenerics> = CoreColumn<TGenerics> &
|
|
175
|
+
| ((props: TProps) => unknown)
|
|
176
|
+
|
|
177
|
+
export type ColumnDef<TData extends RowData> = CoreColumnDef<TData> &
|
|
178
|
+
VisibilityColumnDef &
|
|
179
|
+
ColumnPinningColumnDef &
|
|
180
|
+
FiltersColumnDef<TData> &
|
|
181
|
+
SortingColumnDef<TData> &
|
|
182
|
+
GroupingColumnDef<TData> &
|
|
183
|
+
ColumnSizingColumnDef
|
|
184
|
+
|
|
185
|
+
export type Column<TData extends RowData> = CoreColumn<TData> &
|
|
189
186
|
ColumnVisibilityColumn &
|
|
190
187
|
ColumnPinningColumn &
|
|
191
|
-
FiltersColumn<
|
|
192
|
-
SortingColumn<
|
|
193
|
-
GroupingColumn<
|
|
194
|
-
ColumnSizingColumn
|
|
188
|
+
FiltersColumn<TData> &
|
|
189
|
+
SortingColumn<TData> &
|
|
190
|
+
GroupingColumn<TData> &
|
|
191
|
+
ColumnSizingColumn
|
|
195
192
|
|
|
196
|
-
export type Cell<
|
|
197
|
-
GroupingCell<TGenerics>
|
|
193
|
+
export type Cell<TData extends RowData> = CoreCell<TData> & GroupingCell
|
|
198
194
|
|
|
199
|
-
export type Header<
|
|
200
|
-
ColumnSizingHeader
|
|
195
|
+
export type Header<TData extends RowData> = CoreHeader<TData> &
|
|
196
|
+
ColumnSizingHeader
|
|
201
197
|
|
|
202
|
-
export type HeaderGroup<
|
|
203
|
-
CoreHeaderGroup<TGenerics>
|
|
198
|
+
export type HeaderGroup<TData extends RowData> = CoreHeaderGroup<TData>
|
|
204
199
|
|
|
205
200
|
export type NoInfer<A extends any> = [A][A extends any ? 0 : never]
|
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
import { createRow } from '../core/row'
|
|
2
|
-
import { TableGenerics, Row, RowModel,
|
|
2
|
+
import { TableGenerics, Row, RowModel, Table, RowData } from '../types'
|
|
3
3
|
|
|
4
|
-
export function filterRows<
|
|
5
|
-
rows: Row<
|
|
6
|
-
filterRowImpl: (row: Row<
|
|
7
|
-
|
|
4
|
+
export function filterRows<TData extends RowData>(
|
|
5
|
+
rows: Row<TData>[],
|
|
6
|
+
filterRowImpl: (row: Row<TData>) => any,
|
|
7
|
+
table: Table<TData>
|
|
8
8
|
) {
|
|
9
|
-
if (
|
|
10
|
-
return filterRowModelFromLeafs(rows, filterRowImpl,
|
|
9
|
+
if (table.options.filterFromLeafRows) {
|
|
10
|
+
return filterRowModelFromLeafs(rows, filterRowImpl, table)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
return filterRowModelFromRoot(rows, filterRowImpl,
|
|
13
|
+
return filterRowModelFromRoot(rows, filterRowImpl, table)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function filterRowModelFromLeafs<
|
|
17
|
-
rowsToFilter: Row<
|
|
18
|
-
filterRow: (row: Row<
|
|
19
|
-
|
|
20
|
-
): RowModel<
|
|
21
|
-
const newFilteredFlatRows: Row<
|
|
22
|
-
const newFilteredRowsById: Record<string, Row<
|
|
16
|
+
export function filterRowModelFromLeafs<TData extends RowData>(
|
|
17
|
+
rowsToFilter: Row<TData>[],
|
|
18
|
+
filterRow: (row: Row<TData>) => Row<TData>[],
|
|
19
|
+
table: Table<TData>
|
|
20
|
+
): RowModel<TData> {
|
|
21
|
+
const newFilteredFlatRows: Row<TData>[] = []
|
|
22
|
+
const newFilteredRowsById: Record<string, Row<TData>> = {}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const rows: Row<TGenerics>[] = []
|
|
24
|
+
const recurseFilterRows = (rowsToFilter: Row<TData>[], depth = 0) => {
|
|
25
|
+
const rows: Row<TData>[] = []
|
|
27
26
|
|
|
28
27
|
// Filter from children up first
|
|
29
28
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
30
29
|
let row = rowsToFilter[i]!
|
|
31
30
|
|
|
32
31
|
if (row.subRows?.length) {
|
|
33
|
-
const newRow = createRow(
|
|
32
|
+
const newRow = createRow(
|
|
33
|
+
table,
|
|
34
|
+
row.id,
|
|
35
|
+
row.original,
|
|
36
|
+
row.index,
|
|
37
|
+
row.depth
|
|
38
|
+
)
|
|
34
39
|
newRow.columnFilters = row.columnFilters
|
|
35
40
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1)
|
|
36
41
|
if (!newRow.subRows.length) {
|
|
@@ -56,16 +61,16 @@ export function filterRowModelFromLeafs<TGenerics extends TableGenerics>(
|
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
export function filterRowModelFromRoot<
|
|
60
|
-
rowsToFilter: Row<
|
|
61
|
-
filterRow: (row: Row<
|
|
62
|
-
|
|
63
|
-
): RowModel<
|
|
64
|
-
const newFilteredFlatRows: Row<
|
|
65
|
-
const newFilteredRowsById: Record<string, Row<
|
|
64
|
+
export function filterRowModelFromRoot<TData extends RowData>(
|
|
65
|
+
rowsToFilter: Row<TData>[],
|
|
66
|
+
filterRow: (row: Row<TData>) => any,
|
|
67
|
+
table: Table<TData>
|
|
68
|
+
): RowModel<TData> {
|
|
69
|
+
const newFilteredFlatRows: Row<TData>[] = []
|
|
70
|
+
const newFilteredRowsById: Record<string, Row<TData>> = {}
|
|
66
71
|
|
|
67
72
|
// Filters top level and nested rows
|
|
68
|
-
const recurseFilterRows = (rowsToFilter: Row<
|
|
73
|
+
const recurseFilterRows = (rowsToFilter: Row<TData>[], depth = 0) => {
|
|
69
74
|
// Filter from parents downward first
|
|
70
75
|
|
|
71
76
|
const rows = []
|
|
@@ -79,7 +84,7 @@ export function filterRowModelFromRoot<TGenerics extends TableGenerics>(
|
|
|
79
84
|
if (pass) {
|
|
80
85
|
if (row.subRows?.length) {
|
|
81
86
|
const newRow = createRow(
|
|
82
|
-
|
|
87
|
+
table,
|
|
83
88
|
row.id,
|
|
84
89
|
row.original,
|
|
85
90
|
row.index,
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { createRow } from '../core/row'
|
|
2
|
-
import {
|
|
2
|
+
import { Table, Row, RowModel, TableGenerics, RowData } from '../types'
|
|
3
3
|
import { memo } from '../utils'
|
|
4
4
|
|
|
5
|
-
export function getCoreRowModel<
|
|
6
|
-
|
|
7
|
-
) => () => RowModel<
|
|
8
|
-
return
|
|
5
|
+
export function getCoreRowModel<TData extends RowData>(): (
|
|
6
|
+
table: Table<TData>
|
|
7
|
+
) => () => RowModel<TData> {
|
|
8
|
+
return table =>
|
|
9
9
|
memo(
|
|
10
|
-
() => [
|
|
10
|
+
() => [table.options.data],
|
|
11
11
|
(
|
|
12
12
|
data
|
|
13
13
|
): {
|
|
14
|
-
rows: Row<
|
|
15
|
-
flatRows: Row<
|
|
16
|
-
rowsById: Record<string, Row<
|
|
14
|
+
rows: Row<TData>[]
|
|
15
|
+
flatRows: Row<TData>[]
|
|
16
|
+
rowsById: Record<string, Row<TData>>
|
|
17
17
|
} => {
|
|
18
|
-
const rowModel: RowModel<
|
|
18
|
+
const rowModel: RowModel<TData> = {
|
|
19
19
|
rows: [],
|
|
20
20
|
flatRows: [],
|
|
21
21
|
rowsById: {},
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const accessRows = (
|
|
25
|
-
originalRows:
|
|
25
|
+
originalRows: TData[],
|
|
26
26
|
depth = 0,
|
|
27
|
-
parent?: Row<
|
|
28
|
-
): Row<
|
|
29
|
-
const rows = [] as Row<
|
|
27
|
+
parent?: Row<TData>
|
|
28
|
+
): Row<TData>[] => {
|
|
29
|
+
const rows = [] as Row<TData>[]
|
|
30
30
|
|
|
31
31
|
for (let i = 0; i < originalRows.length; i++) {
|
|
32
32
|
// This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
@@ -38,8 +38,8 @@ export function getCoreRowModel<TGenerics extends TableGenerics>(): (
|
|
|
38
38
|
|
|
39
39
|
// Make the row
|
|
40
40
|
const row = createRow(
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
table,
|
|
42
|
+
table._getRowId(originalRows[i]!, i, parent),
|
|
43
43
|
originalRows[i],
|
|
44
44
|
i,
|
|
45
45
|
depth
|
|
@@ -49,13 +49,13 @@ export function getCoreRowModel<TGenerics extends TableGenerics>(): (
|
|
|
49
49
|
rowModel.flatRows.push(row)
|
|
50
50
|
// Also keep track of every row by its ID
|
|
51
51
|
rowModel.rowsById[row.id] = row
|
|
52
|
-
// Push
|
|
52
|
+
// Push table row into parent
|
|
53
53
|
rows.push(row)
|
|
54
54
|
|
|
55
55
|
// Get the original subrows
|
|
56
|
-
if (
|
|
57
|
-
row.originalSubRows =
|
|
58
|
-
originalRows[i]
|
|
56
|
+
if (table.options.getSubRows) {
|
|
57
|
+
row.originalSubRows = table.options.getSubRows(
|
|
58
|
+
originalRows[i]!,
|
|
59
59
|
i
|
|
60
60
|
)
|
|
61
61
|
|
|
@@ -75,9 +75,9 @@ export function getCoreRowModel<TGenerics extends TableGenerics>(): (
|
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
key: process.env.NODE_ENV === 'development' && 'getRowModel',
|
|
78
|
-
debug: () =>
|
|
78
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
79
79
|
onChange: () => {
|
|
80
|
-
|
|
80
|
+
table._autoResetPageIndex()
|
|
81
81
|
},
|
|
82
82
|
}
|
|
83
83
|
)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Table, Row, RowModel, TableGenerics, RowData } from '../types'
|
|
2
2
|
import { memo } from '../utils'
|
|
3
3
|
|
|
4
|
-
export function getExpandedRowModel<
|
|
5
|
-
|
|
6
|
-
) => () => RowModel<
|
|
7
|
-
return
|
|
4
|
+
export function getExpandedRowModel<TData extends RowData>(): (
|
|
5
|
+
table: Table<TData>
|
|
6
|
+
) => () => RowModel<TData> {
|
|
7
|
+
return table =>
|
|
8
8
|
memo(
|
|
9
9
|
() => [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
table.getState().expanded,
|
|
11
|
+
table.getPreExpandedRowModel(),
|
|
12
|
+
table.options.paginateExpandedRows,
|
|
13
13
|
],
|
|
14
14
|
(expanded, rowModel, paginateExpandedRows) => {
|
|
15
15
|
if (
|
|
@@ -21,22 +21,22 @@ export function getExpandedRowModel<TGenerics extends TableGenerics>(): (
|
|
|
21
21
|
return rowModel
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
return expandRows(rowModel,
|
|
24
|
+
return expandRows(rowModel, table)
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
|
|
28
|
-
debug: () =>
|
|
28
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
29
29
|
}
|
|
30
30
|
)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function expandRows<
|
|
34
|
-
rowModel: RowModel<
|
|
35
|
-
|
|
33
|
+
export function expandRows<TData extends RowData>(
|
|
34
|
+
rowModel: RowModel<TData>,
|
|
35
|
+
table: Table<TData>
|
|
36
36
|
) {
|
|
37
|
-
const expandedRows: Row<
|
|
37
|
+
const expandedRows: Row<TData>[] = []
|
|
38
38
|
|
|
39
|
-
const handleRow = (row: Row<
|
|
39
|
+
const handleRow = (row: Row<TData>) => {
|
|
40
40
|
expandedRows.push(row)
|
|
41
41
|
|
|
42
42
|
if (row.subRows?.length && row.getIsExpanded()) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Table, TableGenerics, RowData } from '../types'
|
|
2
2
|
import { memo } from '../utils'
|
|
3
3
|
|
|
4
|
-
export function getFacetedMinMaxValues<
|
|
5
|
-
|
|
4
|
+
export function getFacetedMinMaxValues<TData extends RowData>(): (
|
|
5
|
+
table: Table<TData>,
|
|
6
6
|
columnId: string
|
|
7
7
|
) => () => undefined | [number, number] {
|
|
8
|
-
return (
|
|
8
|
+
return (table, columnId) =>
|
|
9
9
|
memo(
|
|
10
|
-
() => [
|
|
10
|
+
() => [table.getColumn(columnId).getFacetedRowModel()],
|
|
11
11
|
facetedRowModel => {
|
|
12
12
|
const firstValue = facetedRowModel.flatRows[0]?.getValue(columnId)
|
|
13
13
|
|
|
@@ -33,7 +33,7 @@ export function getFacetedMinMaxValues<TGenerics extends TableGenerics>(): (
|
|
|
33
33
|
key:
|
|
34
34
|
process.env.NODE_ENV === 'development' &&
|
|
35
35
|
'getFacetedMinMaxValues_' + columnId,
|
|
36
|
-
debug: () =>
|
|
36
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
37
37
|
onChange: () => {},
|
|
38
38
|
}
|
|
39
39
|
)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Table, RowModel, TableGenerics, Row, RowData } from '../types'
|
|
2
2
|
import { memo } from '../utils'
|
|
3
3
|
import { filterRows } from './filterRowsUtils'
|
|
4
4
|
|
|
5
|
-
export function getFacetedRowModel<
|
|
6
|
-
|
|
5
|
+
export function getFacetedRowModel<TData extends RowData>(): (
|
|
6
|
+
table: Table<TData>,
|
|
7
7
|
columnId: string
|
|
8
|
-
) => () => RowModel<
|
|
9
|
-
return (
|
|
8
|
+
) => () => RowModel<TData> {
|
|
9
|
+
return (table, columnId) =>
|
|
10
10
|
memo(
|
|
11
11
|
() => [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
table.getPreFilteredRowModel(),
|
|
13
|
+
table.getState().columnFilters,
|
|
14
|
+
table.getState().globalFilter,
|
|
15
|
+
table.getFilteredRowModel(),
|
|
16
16
|
],
|
|
17
17
|
(preRowModel, columnFilters, globalFilter) => {
|
|
18
18
|
if (
|
|
@@ -27,7 +27,7 @@ export function getFacetedRowModel<TGenerics extends TableGenerics>(): (
|
|
|
27
27
|
globalFilter ? '__global__' : undefined,
|
|
28
28
|
].filter(Boolean) as string[]
|
|
29
29
|
|
|
30
|
-
const filterRowsImpl = (row: Row<
|
|
30
|
+
const filterRowsImpl = (row: Row<TData>) => {
|
|
31
31
|
// Horizontally filter rows through each column
|
|
32
32
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
33
33
|
if (row.columnFilters[filterableIds[i]!] === false) {
|
|
@@ -37,13 +37,13 @@ export function getFacetedRowModel<TGenerics extends TableGenerics>(): (
|
|
|
37
37
|
return true
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return filterRows(preRowModel.rows, filterRowsImpl,
|
|
40
|
+
return filterRows(preRowModel.rows, filterRowsImpl, table)
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
key:
|
|
44
44
|
process.env.NODE_ENV === 'development' &&
|
|
45
45
|
'getFacetedRowModel_' + columnId,
|
|
46
|
-
debug: () =>
|
|
46
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
47
47
|
onChange: () => {},
|
|
48
48
|
}
|
|
49
49
|
)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Table, TableGenerics, RowData } from '../types'
|
|
2
2
|
import { memo } from '../utils'
|
|
3
3
|
|
|
4
|
-
export function getFacetedUniqueValues<
|
|
5
|
-
|
|
4
|
+
export function getFacetedUniqueValues<TData extends RowData>(): (
|
|
5
|
+
table: Table<TData>,
|
|
6
6
|
columnId: string
|
|
7
7
|
) => () => Map<any, number> {
|
|
8
|
-
return (
|
|
8
|
+
return (table, columnId) =>
|
|
9
9
|
memo(
|
|
10
|
-
() => [
|
|
10
|
+
() => [table.getColumn(columnId).getFacetedRowModel()],
|
|
11
11
|
facetedRowModel => {
|
|
12
12
|
let facetedUniqueValues = new Map<any, number>()
|
|
13
13
|
|
|
@@ -30,7 +30,7 @@ export function getFacetedUniqueValues<TGenerics extends TableGenerics>(): (
|
|
|
30
30
|
key:
|
|
31
31
|
process.env.NODE_ENV === 'development' &&
|
|
32
32
|
'getFacetedUniqueValues_' + columnId,
|
|
33
|
-
debug: () =>
|
|
33
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
34
34
|
onChange: () => {},
|
|
35
35
|
}
|
|
36
36
|
)
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ResolvedColumnFilter } from '../features/Filters'
|
|
2
|
-
import {
|
|
2
|
+
import { Table, RowModel, TableGenerics, Row, RowData } from '../types'
|
|
3
3
|
import { memo } from '../utils'
|
|
4
4
|
import { filterRows } from './filterRowsUtils'
|
|
5
5
|
|
|
6
|
-
export function getFilteredRowModel<
|
|
7
|
-
|
|
8
|
-
) => () => RowModel<
|
|
9
|
-
return
|
|
6
|
+
export function getFilteredRowModel<TData extends RowData>(): (
|
|
7
|
+
table: Table<TData>
|
|
8
|
+
) => () => RowModel<TData> {
|
|
9
|
+
return table =>
|
|
10
10
|
memo(
|
|
11
11
|
() => [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
table.getPreFilteredRowModel(),
|
|
13
|
+
table.getState().columnFilters,
|
|
14
|
+
table.getState().globalFilter,
|
|
15
15
|
],
|
|
16
16
|
(rowModel, columnFilters, globalFilter) => {
|
|
17
17
|
if (
|
|
@@ -25,11 +25,11 @@ export function getFilteredRowModel<TGenerics extends TableGenerics>(): (
|
|
|
25
25
|
return rowModel
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const resolvedColumnFilters: ResolvedColumnFilter<
|
|
29
|
-
const resolvedGlobalFilters: ResolvedColumnFilter<
|
|
28
|
+
const resolvedColumnFilters: ResolvedColumnFilter<TData>[] = []
|
|
29
|
+
const resolvedGlobalFilters: ResolvedColumnFilter<TData>[] = []
|
|
30
30
|
|
|
31
31
|
;(columnFilters ?? []).forEach(d => {
|
|
32
|
-
const column =
|
|
32
|
+
const column = table.getColumn(d.id)
|
|
33
33
|
|
|
34
34
|
if (!column) {
|
|
35
35
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -59,9 +59,9 @@ export function getFilteredRowModel<TGenerics extends TableGenerics>(): (
|
|
|
59
59
|
|
|
60
60
|
const filterableIds = columnFilters.map(d => d.id)
|
|
61
61
|
|
|
62
|
-
const globalFilterFn =
|
|
62
|
+
const globalFilterFn = table.getGlobalFilterFn()
|
|
63
63
|
|
|
64
|
-
const globallyFilterableColumns =
|
|
64
|
+
const globallyFilterableColumns = table
|
|
65
65
|
.getAllLeafColumns()
|
|
66
66
|
.filter(column => column.getCanGlobalFilter())
|
|
67
67
|
|
|
@@ -135,7 +135,7 @@ export function getFilteredRowModel<TGenerics extends TableGenerics>(): (
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const filterRowsImpl = (row: Row<
|
|
138
|
+
const filterRowsImpl = (row: Row<TData>) => {
|
|
139
139
|
// Horizontally filter rows through each column
|
|
140
140
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
141
141
|
if (row.columnFilters[filterableIds[i]!] === false) {
|
|
@@ -146,13 +146,13 @@ export function getFilteredRowModel<TGenerics extends TableGenerics>(): (
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// Filter final rows using all of the active filters
|
|
149
|
-
return filterRows(rowModel.rows, filterRowsImpl,
|
|
149
|
+
return filterRows(rowModel.rows, filterRowsImpl, table)
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
key: process.env.NODE_ENV === 'development' && 'getFilteredRowModel',
|
|
153
|
-
debug: () =>
|
|
153
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
154
154
|
onChange: () => {
|
|
155
|
-
|
|
155
|
+
table._autoResetPageIndex()
|
|
156
156
|
},
|
|
157
157
|
}
|
|
158
158
|
)
|