@tanstack/react-table 8.0.0-alpha.6 → 8.0.0-alpha.9
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 +66 -73
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +47 -33
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +23 -22
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +10 -22
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +27 -58
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +10 -27
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +108 -28
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +2 -2
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +24 -29
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +23 -38
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +10 -22
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +10 -2
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterTypes.js.map +1 -1
- package/build/cjs/index.js +12 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/types.js +22 -0
- package/build/cjs/types.js.map +1 -0
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/paginateRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +44 -18
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +1388 -1355
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +337 -307
- package/build/types/core.d.ts +63 -67
- package/build/types/createTable.d.ts +34 -44
- package/build/types/features/ColumnSizing.d.ts +13 -7
- package/build/types/features/Expanding.d.ts +11 -16
- package/build/types/features/Filters.d.ts +39 -47
- package/build/types/features/Grouping.d.ts +28 -27
- package/build/types/features/Headers.d.ts +30 -30
- package/build/types/features/Ordering.d.ts +5 -5
- package/build/types/features/Pagination.d.ts +11 -16
- package/build/types/features/Pinning.d.ts +5 -5
- package/build/types/features/RowSelection.d.ts +15 -23
- package/build/types/features/Sorting.d.ts +26 -25
- package/build/types/features/Visibility.d.ts +9 -9
- package/build/types/filterTypes.d.ts +10 -10
- package/build/types/index.d.ts +1 -0
- package/build/types/sortTypes.d.ts +7 -7
- package/build/types/types.d.ts +34 -23
- package/build/types/utils/columnFilterRowsFn.d.ts +2 -2
- package/build/types/utils/expandRowsFn.d.ts +2 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +2 -2
- package/build/types/utils/groupRowsFn.d.ts +2 -2
- package/build/types/utils/paginateRowsFn.d.ts +2 -2
- package/build/types/utils/sortRowsFn.d.ts +2 -2
- package/build/types/utils.d.ts +5 -6
- package/build/umd/index.development.js +1397 -1354
- 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.tsx +192 -520
- package/src/createTable.tsx +137 -192
- package/src/features/ColumnSizing.ts +48 -77
- package/src/features/Expanding.ts +25 -113
- package/src/features/Filters.ts +91 -293
- package/src/features/Grouping.ts +60 -165
- package/src/features/Headers.ts +148 -331
- package/src/features/Ordering.ts +19 -42
- package/src/features/Pagination.ts +35 -110
- package/src/features/Pinning.ts +16 -40
- package/src/features/RowSelection.ts +47 -227
- package/src/features/Sorting.ts +49 -143
- package/src/features/Visibility.ts +23 -64
- package/src/filterTypes.ts +19 -82
- package/src/index.tsx +1 -0
- package/src/sortTypes.ts +19 -31
- package/src/types.ts +80 -100
- package/src/utils/columnFilterRowsFn.ts +11 -53
- package/src/utils/expandRowsFn.ts +7 -27
- package/src/utils/globalFilterRowsFn.ts +10 -43
- package/src/utils/groupRowsFn.ts +13 -37
- package/src/utils/paginateRowsFn.ts +5 -11
- package/src/utils/sortRowsFn.ts +8 -28
- package/src/utils.tsx +61 -35
package/src/features/Headers.ts
CHANGED
|
@@ -9,194 +9,53 @@ import {
|
|
|
9
9
|
HeaderGroup,
|
|
10
10
|
HeaderGroupProps,
|
|
11
11
|
HeaderProps,
|
|
12
|
+
PartialGenerics,
|
|
12
13
|
PropGetterValue,
|
|
13
|
-
|
|
14
|
+
TableInstance,
|
|
14
15
|
Row,
|
|
15
16
|
} from '../types'
|
|
16
17
|
import { propGetter, memo, flexRender } from '../utils'
|
|
17
|
-
|
|
18
18
|
import * as ColumnSizing from './ColumnSizing'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
TAggregationFns
|
|
27
|
-
> = {
|
|
28
|
-
_getAllVisibleCells: () => Cell<
|
|
29
|
-
TData,
|
|
30
|
-
TValue,
|
|
31
|
-
TFilterFns,
|
|
32
|
-
TSortingFns,
|
|
33
|
-
TAggregationFns
|
|
34
|
-
>[]
|
|
35
|
-
getVisibleCells: () => Cell<
|
|
36
|
-
TData,
|
|
37
|
-
TValue,
|
|
38
|
-
TFilterFns,
|
|
39
|
-
TSortingFns,
|
|
40
|
-
TAggregationFns
|
|
41
|
-
>[]
|
|
42
|
-
getLeftVisibleCells: () => Cell<
|
|
43
|
-
TData,
|
|
44
|
-
TValue,
|
|
45
|
-
TFilterFns,
|
|
46
|
-
TSortingFns,
|
|
47
|
-
TAggregationFns
|
|
48
|
-
>[]
|
|
49
|
-
getCenterVisibleCells: () => Cell<
|
|
50
|
-
TData,
|
|
51
|
-
TValue,
|
|
52
|
-
TFilterFns,
|
|
53
|
-
TSortingFns,
|
|
54
|
-
TAggregationFns
|
|
55
|
-
>[]
|
|
56
|
-
getRightVisibleCells: () => Cell<
|
|
57
|
-
TData,
|
|
58
|
-
TValue,
|
|
59
|
-
TFilterFns,
|
|
60
|
-
TSortingFns,
|
|
61
|
-
TAggregationFns
|
|
62
|
-
>[]
|
|
19
|
+
|
|
20
|
+
export type HeadersRow<TGenerics extends PartialGenerics> = {
|
|
21
|
+
_getAllVisibleCells: () => Cell<TGenerics>[]
|
|
22
|
+
getVisibleCells: () => Cell<TGenerics>[]
|
|
23
|
+
getLeftVisibleCells: () => Cell<TGenerics>[]
|
|
24
|
+
getCenterVisibleCells: () => Cell<TGenerics>[]
|
|
25
|
+
getRightVisibleCells: () => Cell<TGenerics>[]
|
|
63
26
|
}
|
|
64
27
|
|
|
65
|
-
export type HeadersInstance<
|
|
66
|
-
TData,
|
|
67
|
-
TValue,
|
|
68
|
-
TFilterFns,
|
|
69
|
-
TSortingFns,
|
|
70
|
-
TAggregationFns
|
|
71
|
-
> = {
|
|
28
|
+
export type HeadersInstance<TGenerics extends PartialGenerics> = {
|
|
72
29
|
createHeader: (
|
|
73
|
-
column: Column<
|
|
30
|
+
column: Column<TGenerics>,
|
|
74
31
|
options: {
|
|
75
32
|
id?: string
|
|
76
33
|
isPlaceholder?: boolean
|
|
77
34
|
placeholderId?: string
|
|
78
35
|
depth: number
|
|
79
36
|
}
|
|
80
|
-
) => Header<
|
|
81
|
-
getHeaderGroups: () => HeaderGroup<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
>[]
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
>[]
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
>
|
|
102
|
-
getRightHeaderGroups: () => HeaderGroup<
|
|
103
|
-
TData,
|
|
104
|
-
TValue,
|
|
105
|
-
TFilterFns,
|
|
106
|
-
TSortingFns,
|
|
107
|
-
TAggregationFns
|
|
108
|
-
>[]
|
|
109
|
-
|
|
110
|
-
getFooterGroups: () => HeaderGroup<
|
|
111
|
-
TData,
|
|
112
|
-
TValue,
|
|
113
|
-
TFilterFns,
|
|
114
|
-
TSortingFns,
|
|
115
|
-
TAggregationFns
|
|
116
|
-
>[]
|
|
117
|
-
getCenterFooterGroups: () => HeaderGroup<
|
|
118
|
-
TData,
|
|
119
|
-
TValue,
|
|
120
|
-
TFilterFns,
|
|
121
|
-
TSortingFns,
|
|
122
|
-
TAggregationFns
|
|
123
|
-
>[]
|
|
124
|
-
getLeftFooterGroups: () => HeaderGroup<
|
|
125
|
-
TData,
|
|
126
|
-
TValue,
|
|
127
|
-
TFilterFns,
|
|
128
|
-
TSortingFns,
|
|
129
|
-
TAggregationFns
|
|
130
|
-
>[]
|
|
131
|
-
getRightFooterGroups: () => HeaderGroup<
|
|
132
|
-
TData,
|
|
133
|
-
TValue,
|
|
134
|
-
TFilterFns,
|
|
135
|
-
TSortingFns,
|
|
136
|
-
TAggregationFns
|
|
137
|
-
>[]
|
|
138
|
-
|
|
139
|
-
getFlatHeaders: () => Header<
|
|
140
|
-
TData,
|
|
141
|
-
TValue,
|
|
142
|
-
TFilterFns,
|
|
143
|
-
TSortingFns,
|
|
144
|
-
TAggregationFns
|
|
145
|
-
>[]
|
|
146
|
-
getLeftFlatHeaders: () => Header<
|
|
147
|
-
TData,
|
|
148
|
-
TValue,
|
|
149
|
-
TFilterFns,
|
|
150
|
-
TSortingFns,
|
|
151
|
-
TAggregationFns
|
|
152
|
-
>[]
|
|
153
|
-
getCenterFlatHeaders: () => Header<
|
|
154
|
-
TData,
|
|
155
|
-
TValue,
|
|
156
|
-
TFilterFns,
|
|
157
|
-
TSortingFns,
|
|
158
|
-
TAggregationFns
|
|
159
|
-
>[]
|
|
160
|
-
getRightFlatHeaders: () => Header<
|
|
161
|
-
TData,
|
|
162
|
-
TValue,
|
|
163
|
-
TFilterFns,
|
|
164
|
-
TSortingFns,
|
|
165
|
-
TAggregationFns
|
|
166
|
-
>[]
|
|
167
|
-
|
|
168
|
-
getLeafHeaders: () => Header<
|
|
169
|
-
TData,
|
|
170
|
-
TValue,
|
|
171
|
-
TFilterFns,
|
|
172
|
-
TSortingFns,
|
|
173
|
-
TAggregationFns
|
|
174
|
-
>[]
|
|
175
|
-
getLeftLeafHeaders: () => Header<
|
|
176
|
-
TData,
|
|
177
|
-
TValue,
|
|
178
|
-
TFilterFns,
|
|
179
|
-
TSortingFns,
|
|
180
|
-
TAggregationFns
|
|
181
|
-
>[]
|
|
182
|
-
getCenterLeafHeaders: () => Header<
|
|
183
|
-
TData,
|
|
184
|
-
TValue,
|
|
185
|
-
TFilterFns,
|
|
186
|
-
TSortingFns,
|
|
187
|
-
TAggregationFns
|
|
188
|
-
>[]
|
|
189
|
-
getRightLeafHeaders: () => Header<
|
|
190
|
-
TData,
|
|
191
|
-
TValue,
|
|
192
|
-
TFilterFns,
|
|
193
|
-
TSortingFns,
|
|
194
|
-
TAggregationFns
|
|
195
|
-
>[]
|
|
196
|
-
|
|
197
|
-
getHeader: (
|
|
198
|
-
id: string
|
|
199
|
-
) => Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
37
|
+
) => Header<TGenerics>
|
|
38
|
+
getHeaderGroups: () => HeaderGroup<TGenerics>[]
|
|
39
|
+
getLeftHeaderGroups: () => HeaderGroup<TGenerics>[]
|
|
40
|
+
getCenterHeaderGroups: () => HeaderGroup<TGenerics>[]
|
|
41
|
+
getRightHeaderGroups: () => HeaderGroup<TGenerics>[]
|
|
42
|
+
|
|
43
|
+
getFooterGroups: () => HeaderGroup<TGenerics>[]
|
|
44
|
+
getLeftFooterGroups: () => HeaderGroup<TGenerics>[]
|
|
45
|
+
getCenterFooterGroups: () => HeaderGroup<TGenerics>[]
|
|
46
|
+
getRightFooterGroups: () => HeaderGroup<TGenerics>[]
|
|
47
|
+
|
|
48
|
+
getFlatHeaders: () => Header<TGenerics>[]
|
|
49
|
+
getLeftFlatHeaders: () => Header<TGenerics>[]
|
|
50
|
+
getCenterFlatHeaders: () => Header<TGenerics>[]
|
|
51
|
+
getRightFlatHeaders: () => Header<TGenerics>[]
|
|
52
|
+
|
|
53
|
+
getLeafHeaders: () => Header<TGenerics>[]
|
|
54
|
+
getLeftLeafHeaders: () => Header<TGenerics>[]
|
|
55
|
+
getCenterLeafHeaders: () => Header<TGenerics>[]
|
|
56
|
+
getRightLeafHeaders: () => Header<TGenerics>[]
|
|
57
|
+
|
|
58
|
+
getHeader: (id: string) => Header<TGenerics>
|
|
200
59
|
|
|
201
60
|
getHeaderGroupProps: <TGetter extends Getter<HeaderGroupProps>>(
|
|
202
61
|
id: string,
|
|
@@ -219,16 +78,10 @@ export type HeadersInstance<
|
|
|
219
78
|
|
|
220
79
|
//
|
|
221
80
|
|
|
222
|
-
export function createRow<
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
TSortingFns,
|
|
227
|
-
TAggregationFns
|
|
228
|
-
>(
|
|
229
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
230
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
231
|
-
): HeadersRow<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
81
|
+
export function createRow<TGenerics extends PartialGenerics>(
|
|
82
|
+
row: Row<TGenerics>,
|
|
83
|
+
instance: TableInstance<TGenerics>
|
|
84
|
+
): HeadersRow<TGenerics> {
|
|
232
85
|
return {
|
|
233
86
|
_getAllVisibleCells: memo(
|
|
234
87
|
() => [
|
|
@@ -241,7 +94,10 @@ export function createRow<
|
|
|
241
94
|
_ => {
|
|
242
95
|
return row.getAllCells().filter(cell => cell.column.getIsVisible())
|
|
243
96
|
},
|
|
244
|
-
{
|
|
97
|
+
{
|
|
98
|
+
key: 'row._getAllVisibleCells',
|
|
99
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
100
|
+
}
|
|
245
101
|
),
|
|
246
102
|
getVisibleCells: memo(
|
|
247
103
|
() => [
|
|
@@ -250,7 +106,10 @@ export function createRow<
|
|
|
250
106
|
row.getRightVisibleCells(),
|
|
251
107
|
],
|
|
252
108
|
(left, center, right) => [...left, ...center, ...right],
|
|
253
|
-
{
|
|
109
|
+
{
|
|
110
|
+
key: 'row.getVisibleCells',
|
|
111
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
112
|
+
}
|
|
254
113
|
),
|
|
255
114
|
getCenterVisibleCells: memo(
|
|
256
115
|
() => [
|
|
@@ -263,7 +122,10 @@ export function createRow<
|
|
|
263
122
|
|
|
264
123
|
return allCells.filter(d => !leftAndRight.includes(d.columnId))
|
|
265
124
|
},
|
|
266
|
-
{
|
|
125
|
+
{
|
|
126
|
+
key: 'row.getCenterVisibleCells',
|
|
127
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
128
|
+
}
|
|
267
129
|
),
|
|
268
130
|
getLeftVisibleCells: memo(
|
|
269
131
|
() => [
|
|
@@ -278,7 +140,10 @@ export function createRow<
|
|
|
278
140
|
|
|
279
141
|
return cells
|
|
280
142
|
},
|
|
281
|
-
{
|
|
143
|
+
{
|
|
144
|
+
key: 'row.getLeftVisibleCells',
|
|
145
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
146
|
+
}
|
|
282
147
|
),
|
|
283
148
|
getRightVisibleCells: memo(
|
|
284
149
|
() => [
|
|
@@ -292,23 +157,20 @@ export function createRow<
|
|
|
292
157
|
|
|
293
158
|
return cells
|
|
294
159
|
},
|
|
295
|
-
{
|
|
160
|
+
{
|
|
161
|
+
key: 'row.getRightVisibleCells',
|
|
162
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
163
|
+
}
|
|
296
164
|
),
|
|
297
165
|
}
|
|
298
166
|
}
|
|
299
167
|
|
|
300
|
-
export function getInstance<
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
TFilterFns,
|
|
304
|
-
TSortingFns,
|
|
305
|
-
TAggregationFns
|
|
306
|
-
>(
|
|
307
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
308
|
-
): HeadersInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
168
|
+
export function getInstance<TGenerics extends PartialGenerics>(
|
|
169
|
+
instance: TableInstance<TGenerics>
|
|
170
|
+
): HeadersInstance<TGenerics> {
|
|
309
171
|
return {
|
|
310
172
|
createHeader: (
|
|
311
|
-
column: Column<
|
|
173
|
+
column: Column<TGenerics>,
|
|
312
174
|
options: {
|
|
313
175
|
id?: string
|
|
314
176
|
isPlaceholder?: boolean
|
|
@@ -318,13 +180,7 @@ export function getInstance<
|
|
|
318
180
|
) => {
|
|
319
181
|
const id = options.id ?? column.id
|
|
320
182
|
|
|
321
|
-
let header: CoreHeader<
|
|
322
|
-
TData,
|
|
323
|
-
TValue,
|
|
324
|
-
TFilterFns,
|
|
325
|
-
TSortingFns,
|
|
326
|
-
TAggregationFns
|
|
327
|
-
> = {
|
|
183
|
+
let header: CoreHeader<TGenerics> = {
|
|
328
184
|
id,
|
|
329
185
|
column,
|
|
330
186
|
isPlaceholder: options.isPlaceholder,
|
|
@@ -336,15 +192,7 @@ export function getInstance<
|
|
|
336
192
|
getWidth: () => {
|
|
337
193
|
let sum = 0
|
|
338
194
|
|
|
339
|
-
const recurse = (
|
|
340
|
-
header: CoreHeader<
|
|
341
|
-
TData,
|
|
342
|
-
TValue,
|
|
343
|
-
TFilterFns,
|
|
344
|
-
TSortingFns,
|
|
345
|
-
TAggregationFns
|
|
346
|
-
>
|
|
347
|
-
) => {
|
|
195
|
+
const recurse = (header: CoreHeader<TGenerics>) => {
|
|
348
196
|
if (header.subHeaders.length) {
|
|
349
197
|
header.subHeaders.forEach(recurse)
|
|
350
198
|
} else {
|
|
@@ -356,30 +204,10 @@ export function getInstance<
|
|
|
356
204
|
|
|
357
205
|
return sum
|
|
358
206
|
},
|
|
359
|
-
getLeafHeaders: (): Header<
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
TSortingFns,
|
|
364
|
-
TAggregationFns
|
|
365
|
-
>[] => {
|
|
366
|
-
const leafHeaders: CoreHeader<
|
|
367
|
-
TData,
|
|
368
|
-
TValue,
|
|
369
|
-
TFilterFns,
|
|
370
|
-
TSortingFns,
|
|
371
|
-
TAggregationFns
|
|
372
|
-
>[] = []
|
|
373
|
-
|
|
374
|
-
const recurseHeader = (
|
|
375
|
-
h: CoreHeader<
|
|
376
|
-
TData,
|
|
377
|
-
TValue,
|
|
378
|
-
TFilterFns,
|
|
379
|
-
TSortingFns,
|
|
380
|
-
TAggregationFns
|
|
381
|
-
>
|
|
382
|
-
) => {
|
|
207
|
+
getLeafHeaders: (): Header<TGenerics>[] => {
|
|
208
|
+
const leafHeaders: CoreHeader<TGenerics>[] = []
|
|
209
|
+
|
|
210
|
+
const recurseHeader = (h: CoreHeader<TGenerics>) => {
|
|
383
211
|
if (h.subHeaders && h.subHeaders.length) {
|
|
384
212
|
h.subHeaders.map(recurseHeader)
|
|
385
213
|
}
|
|
@@ -388,13 +216,7 @@ export function getInstance<
|
|
|
388
216
|
|
|
389
217
|
recurseHeader(header)
|
|
390
218
|
|
|
391
|
-
return leafHeaders as Header<
|
|
392
|
-
TData,
|
|
393
|
-
TValue,
|
|
394
|
-
TFilterFns,
|
|
395
|
-
TSortingFns,
|
|
396
|
-
TAggregationFns
|
|
397
|
-
>[]
|
|
219
|
+
return leafHeaders as Header<TGenerics>[]
|
|
398
220
|
},
|
|
399
221
|
getHeaderProps: userProps =>
|
|
400
222
|
instance.getHeaderProps(header.id, userProps)!,
|
|
@@ -406,14 +228,11 @@ export function getInstance<
|
|
|
406
228
|
flexRender(column.footer, { instance, header, column }),
|
|
407
229
|
}
|
|
408
230
|
|
|
409
|
-
// Yes, we have to convert instance to
|
|
410
|
-
return
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
TSortingFns,
|
|
415
|
-
TAggregationFns
|
|
416
|
-
>
|
|
231
|
+
// Yes, we have to convert instance to unknown, because we know more than the compiler here.
|
|
232
|
+
return Object.assign(
|
|
233
|
+
header,
|
|
234
|
+
ColumnSizing.createHeader(header as Header<TGenerics>, instance)
|
|
235
|
+
) as Header<TGenerics>
|
|
417
236
|
},
|
|
418
237
|
|
|
419
238
|
// Header Groups
|
|
@@ -443,7 +262,10 @@ export function getInstance<
|
|
|
443
262
|
|
|
444
263
|
return headerGroups
|
|
445
264
|
},
|
|
446
|
-
{
|
|
265
|
+
{
|
|
266
|
+
key: 'getHeaderGroups',
|
|
267
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
268
|
+
}
|
|
447
269
|
),
|
|
448
270
|
|
|
449
271
|
getCenterHeaderGroups: memo(
|
|
@@ -459,7 +281,10 @@ export function getInstance<
|
|
|
459
281
|
)
|
|
460
282
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'center')
|
|
461
283
|
},
|
|
462
|
-
{
|
|
284
|
+
{
|
|
285
|
+
key: 'getCenterHeaderGroups',
|
|
286
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
287
|
+
}
|
|
463
288
|
),
|
|
464
289
|
|
|
465
290
|
getLeftHeaderGroups: memo(
|
|
@@ -472,7 +297,10 @@ export function getInstance<
|
|
|
472
297
|
leafColumns = leafColumns.filter(column => left?.includes(column.id))
|
|
473
298
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'left')
|
|
474
299
|
},
|
|
475
|
-
{
|
|
300
|
+
{
|
|
301
|
+
key: 'getLeftHeaderGroups',
|
|
302
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
303
|
+
}
|
|
476
304
|
),
|
|
477
305
|
|
|
478
306
|
getRightHeaderGroups: memo(
|
|
@@ -485,7 +313,10 @@ export function getInstance<
|
|
|
485
313
|
leafColumns = leafColumns.filter(column => right?.includes(column.id))
|
|
486
314
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'right')
|
|
487
315
|
},
|
|
488
|
-
{
|
|
316
|
+
{
|
|
317
|
+
key: 'getRightHeaderGroups',
|
|
318
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
319
|
+
}
|
|
489
320
|
),
|
|
490
321
|
|
|
491
322
|
// Footer Groups
|
|
@@ -495,7 +326,10 @@ export function getInstance<
|
|
|
495
326
|
headerGroups => {
|
|
496
327
|
return [...headerGroups].reverse()
|
|
497
328
|
},
|
|
498
|
-
{
|
|
329
|
+
{
|
|
330
|
+
key: 'getFooterGroups',
|
|
331
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
332
|
+
}
|
|
499
333
|
),
|
|
500
334
|
|
|
501
335
|
getLeftFooterGroups: memo(
|
|
@@ -503,7 +337,10 @@ export function getInstance<
|
|
|
503
337
|
headerGroups => {
|
|
504
338
|
return [...headerGroups].reverse()
|
|
505
339
|
},
|
|
506
|
-
{
|
|
340
|
+
{
|
|
341
|
+
key: 'getLeftFooterGroups',
|
|
342
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
343
|
+
}
|
|
507
344
|
),
|
|
508
345
|
|
|
509
346
|
getCenterFooterGroups: memo(
|
|
@@ -511,7 +348,10 @@ export function getInstance<
|
|
|
511
348
|
headerGroups => {
|
|
512
349
|
return [...headerGroups].reverse()
|
|
513
350
|
},
|
|
514
|
-
{
|
|
351
|
+
{
|
|
352
|
+
key: 'getCenterFooterGroups',
|
|
353
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
354
|
+
}
|
|
515
355
|
),
|
|
516
356
|
|
|
517
357
|
getRightFooterGroups: memo(
|
|
@@ -519,7 +359,10 @@ export function getInstance<
|
|
|
519
359
|
headerGroups => {
|
|
520
360
|
return [...headerGroups].reverse()
|
|
521
361
|
},
|
|
522
|
-
{
|
|
362
|
+
{
|
|
363
|
+
key: 'getRightFooterGroups',
|
|
364
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
365
|
+
}
|
|
523
366
|
),
|
|
524
367
|
|
|
525
368
|
// Flat Headers
|
|
@@ -533,7 +376,10 @@ export function getInstance<
|
|
|
533
376
|
})
|
|
534
377
|
.flat()
|
|
535
378
|
},
|
|
536
|
-
{
|
|
379
|
+
{
|
|
380
|
+
key: 'getFlatHeaders',
|
|
381
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
382
|
+
}
|
|
537
383
|
),
|
|
538
384
|
|
|
539
385
|
getLeftFlatHeaders: memo(
|
|
@@ -545,7 +391,10 @@ export function getInstance<
|
|
|
545
391
|
})
|
|
546
392
|
.flat()
|
|
547
393
|
},
|
|
548
|
-
{
|
|
394
|
+
{
|
|
395
|
+
key: 'getLeftFlatHeaders',
|
|
396
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
397
|
+
}
|
|
549
398
|
),
|
|
550
399
|
|
|
551
400
|
getCenterFlatHeaders: memo(
|
|
@@ -557,7 +406,10 @@ export function getInstance<
|
|
|
557
406
|
})
|
|
558
407
|
.flat()
|
|
559
408
|
},
|
|
560
|
-
{
|
|
409
|
+
{
|
|
410
|
+
key: 'getCenterFlatHeaders',
|
|
411
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
412
|
+
}
|
|
561
413
|
),
|
|
562
414
|
|
|
563
415
|
getRightFlatHeaders: memo(
|
|
@@ -569,7 +421,10 @@ export function getInstance<
|
|
|
569
421
|
})
|
|
570
422
|
.flat()
|
|
571
423
|
},
|
|
572
|
-
{
|
|
424
|
+
{
|
|
425
|
+
key: 'getRightFlatHeaders',
|
|
426
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
427
|
+
}
|
|
573
428
|
),
|
|
574
429
|
|
|
575
430
|
// Leaf Headers
|
|
@@ -579,7 +434,10 @@ export function getInstance<
|
|
|
579
434
|
flatHeaders => {
|
|
580
435
|
return flatHeaders.filter(header => !header.subHeaders?.length)
|
|
581
436
|
},
|
|
582
|
-
{
|
|
437
|
+
{
|
|
438
|
+
key: 'getCenterLeafHeaders',
|
|
439
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
440
|
+
}
|
|
583
441
|
),
|
|
584
442
|
|
|
585
443
|
getLeftLeafHeaders: memo(
|
|
@@ -587,7 +445,10 @@ export function getInstance<
|
|
|
587
445
|
flatHeaders => {
|
|
588
446
|
return flatHeaders.filter(header => !header.subHeaders?.length)
|
|
589
447
|
},
|
|
590
|
-
{
|
|
448
|
+
{
|
|
449
|
+
key: 'getLeftLeafHeaders',
|
|
450
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
451
|
+
}
|
|
591
452
|
),
|
|
592
453
|
|
|
593
454
|
getRightLeafHeaders: memo(
|
|
@@ -595,7 +456,10 @@ export function getInstance<
|
|
|
595
456
|
flatHeaders => {
|
|
596
457
|
return flatHeaders.filter(header => !header.subHeaders?.length)
|
|
597
458
|
},
|
|
598
|
-
{
|
|
459
|
+
{
|
|
460
|
+
key: 'getRightLeafHeaders',
|
|
461
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
462
|
+
}
|
|
599
463
|
),
|
|
600
464
|
|
|
601
465
|
getLeafHeaders: memo(
|
|
@@ -615,7 +479,10 @@ export function getInstance<
|
|
|
615
479
|
})
|
|
616
480
|
.flat()
|
|
617
481
|
},
|
|
618
|
-
{
|
|
482
|
+
{
|
|
483
|
+
key: 'getLeafHeaders',
|
|
484
|
+
debug: () => instance.options.debugAll ?? instance.options.debugHeaders,
|
|
485
|
+
}
|
|
619
486
|
),
|
|
620
487
|
|
|
621
488
|
getHeader: (id: string) => {
|
|
@@ -686,9 +553,6 @@ export function getInstance<
|
|
|
686
553
|
|
|
687
554
|
getFooterProps: (id, userProps) => {
|
|
688
555
|
const header = instance.getHeader(id)
|
|
689
|
-
if (!header) {
|
|
690
|
-
return
|
|
691
|
-
}
|
|
692
556
|
|
|
693
557
|
const initialProps: FooterProps = {
|
|
694
558
|
key: header.id,
|
|
@@ -712,22 +576,10 @@ export function getInstance<
|
|
|
712
576
|
}
|
|
713
577
|
}
|
|
714
578
|
|
|
715
|
-
export function buildHeaderGroups<
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
TSortingFns,
|
|
720
|
-
TAggregationFns
|
|
721
|
-
>(
|
|
722
|
-
allColumns: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[],
|
|
723
|
-
columnsToGroup: Column<
|
|
724
|
-
TData,
|
|
725
|
-
TValue,
|
|
726
|
-
TFilterFns,
|
|
727
|
-
TSortingFns,
|
|
728
|
-
TAggregationFns
|
|
729
|
-
>[],
|
|
730
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
579
|
+
export function buildHeaderGroups<TGenerics extends PartialGenerics>(
|
|
580
|
+
allColumns: Column<TGenerics>[],
|
|
581
|
+
columnsToGroup: Column<TGenerics>[],
|
|
582
|
+
instance: TableInstance<TGenerics>,
|
|
731
583
|
headerFamily?: 'center' | 'left' | 'right'
|
|
732
584
|
) {
|
|
733
585
|
// Find the max depth of the columns:
|
|
@@ -738,10 +590,7 @@ export function buildHeaderGroups<
|
|
|
738
590
|
|
|
739
591
|
let maxDepth = 0
|
|
740
592
|
|
|
741
|
-
const findMaxDepth = (
|
|
742
|
-
columns: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[],
|
|
743
|
-
depth = 1
|
|
744
|
-
) => {
|
|
593
|
+
const findMaxDepth = (columns: Column<TGenerics>[], depth = 1) => {
|
|
745
594
|
maxDepth = Math.max(maxDepth, depth)
|
|
746
595
|
|
|
747
596
|
columns
|
|
@@ -755,32 +604,14 @@ export function buildHeaderGroups<
|
|
|
755
604
|
|
|
756
605
|
findMaxDepth(allColumns)
|
|
757
606
|
|
|
758
|
-
let headerGroups: HeaderGroup<
|
|
759
|
-
TData,
|
|
760
|
-
TValue,
|
|
761
|
-
TFilterFns,
|
|
762
|
-
TSortingFns,
|
|
763
|
-
TAggregationFns
|
|
764
|
-
>[] = []
|
|
607
|
+
let headerGroups: HeaderGroup<TGenerics>[] = []
|
|
765
608
|
|
|
766
609
|
const createHeaderGroup = (
|
|
767
|
-
headersToGroup: Header<
|
|
768
|
-
TData,
|
|
769
|
-
TValue,
|
|
770
|
-
TFilterFns,
|
|
771
|
-
TSortingFns,
|
|
772
|
-
TAggregationFns
|
|
773
|
-
>[],
|
|
610
|
+
headersToGroup: Header<TGenerics>[],
|
|
774
611
|
depth: number
|
|
775
612
|
) => {
|
|
776
613
|
// The header group we are creating
|
|
777
|
-
const headerGroup: HeaderGroup<
|
|
778
|
-
TData,
|
|
779
|
-
TValue,
|
|
780
|
-
TFilterFns,
|
|
781
|
-
TSortingFns,
|
|
782
|
-
TAggregationFns
|
|
783
|
-
> = {
|
|
614
|
+
const headerGroup: HeaderGroup<TGenerics> = {
|
|
784
615
|
depth,
|
|
785
616
|
id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
|
|
786
617
|
headers: [],
|
|
@@ -791,13 +622,7 @@ export function buildHeaderGroups<
|
|
|
791
622
|
}
|
|
792
623
|
|
|
793
624
|
// The parent columns we're going to scan next
|
|
794
|
-
const parentHeaders: Header<
|
|
795
|
-
TData,
|
|
796
|
-
TValue,
|
|
797
|
-
TFilterFns,
|
|
798
|
-
TSortingFns,
|
|
799
|
-
TAggregationFns
|
|
800
|
-
>[] = []
|
|
625
|
+
const parentHeaders: Header<TGenerics>[] = []
|
|
801
626
|
|
|
802
627
|
// Scan each column for parents
|
|
803
628
|
headersToGroup.forEach(headerToGroup => {
|
|
@@ -807,13 +632,7 @@ export function buildHeaderGroups<
|
|
|
807
632
|
|
|
808
633
|
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth
|
|
809
634
|
|
|
810
|
-
let column: Column<
|
|
811
|
-
TData,
|
|
812
|
-
TValue,
|
|
813
|
-
TFilterFns,
|
|
814
|
-
TSortingFns,
|
|
815
|
-
TAggregationFns
|
|
816
|
-
>
|
|
635
|
+
let column: Column<TGenerics>
|
|
817
636
|
let isPlaceholder = false
|
|
818
637
|
|
|
819
638
|
if (isLeafHeader && headerToGroup.column.parent) {
|
|
@@ -871,9 +690,7 @@ export function buildHeaderGroups<
|
|
|
871
690
|
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
872
691
|
// })
|
|
873
692
|
|
|
874
|
-
const recurseHeadersForSpans = (
|
|
875
|
-
headers: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[]
|
|
876
|
-
) => {
|
|
693
|
+
const recurseHeadersForSpans = (headers: Header<TGenerics>[]) => {
|
|
877
694
|
const filteredHeaders = headers.filter(header =>
|
|
878
695
|
header.column.getIsVisible()
|
|
879
696
|
)
|