@tanstack/table-core 8.0.0-alpha.55 → 8.0.0-alpha.57
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 +9 -384
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/features/Cells.js +122 -0
- package/build/cjs/features/Cells.js.map +1 -0
- package/build/cjs/features/ColumnSizing.js +90 -37
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Columns.js +216 -0
- package/build/cjs/features/Columns.js.map +1 -0
- package/build/cjs/features/Expanding.js +1 -1
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +1 -1
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +1 -1
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +78 -153
- 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 +172 -2
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Rows.js +99 -0
- package/build/cjs/features/Rows.js.map +1 -0
- package/build/cjs/features/Sorting.js +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +51 -17
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +876 -690
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +418 -316
- package/build/types/core.d.ts +2 -79
- package/build/types/features/Cells.d.ts +14 -0
- package/build/types/features/ColumnSizing.d.ts +23 -15
- package/build/types/features/Columns.d.ts +54 -0
- package/build/types/features/Expanding.d.ts +1 -1
- package/build/types/features/Filters.d.ts +1 -1
- package/build/types/features/Grouping.d.ts +1 -1
- package/build/types/features/Headers.d.ts +3 -11
- package/build/types/features/Ordering.d.ts +1 -1
- package/build/types/features/Pagination.d.ts +1 -1
- package/build/types/features/Pinning.d.ts +18 -4
- package/build/types/features/RowSelection.d.ts +1 -1
- package/build/types/features/Rows.d.ts +29 -0
- package/build/types/features/Sorting.d.ts +1 -1
- package/build/types/features/Visibility.d.ts +7 -2
- package/build/types/types.d.ts +18 -10
- package/build/types/utils.d.ts +0 -1
- package/build/umd/index.development.js +854 -668
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/core.ts +28 -550
- package/src/features/Cells.ts +156 -0
- package/src/features/ColumnSizing.ts +99 -47
- package/src/features/Columns.ts +290 -0
- package/src/features/Expanding.ts +1 -1
- package/src/features/Filters.ts +1 -1
- package/src/features/Grouping.ts +1 -1
- package/src/features/Headers.ts +48 -138
- package/src/features/Ordering.ts +1 -1
- package/src/features/Pagination.ts +1 -1
- package/src/features/Pinning.ts +194 -3
- package/src/features/RowSelection.ts +1 -1
- package/src/features/Rows.ts +151 -0
- package/src/features/Sorting.ts +1 -1
- package/src/features/Visibility.ts +67 -20
- package/src/types.ts +25 -37
- package/src/utils.ts +1 -3
package/src/features/Filters.ts
CHANGED
|
@@ -230,7 +230,7 @@ export const Filters = {
|
|
|
230
230
|
}
|
|
231
231
|
},
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
234
234
|
instance: TableInstance<TGenerics>
|
|
235
235
|
): FiltersInstance<TGenerics> => {
|
|
236
236
|
let registered = false
|
package/src/features/Grouping.ts
CHANGED
|
@@ -178,7 +178,7 @@ export const Grouping = {
|
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
182
182
|
instance: TableInstance<TGenerics>
|
|
183
183
|
): GroupingInstance<TGenerics> => {
|
|
184
184
|
let registered = false
|
package/src/features/Headers.ts
CHANGED
|
@@ -15,15 +15,6 @@ import {
|
|
|
15
15
|
Row,
|
|
16
16
|
} from '../types'
|
|
17
17
|
import { propGetter, memo } from '../utils'
|
|
18
|
-
import { ColumnSizing } from './ColumnSizing'
|
|
19
|
-
|
|
20
|
-
export type HeadersRow<TGenerics extends TableGenerics> = {
|
|
21
|
-
_getAllVisibleCells: () => Cell<TGenerics>[]
|
|
22
|
-
getVisibleCells: () => Cell<TGenerics>[]
|
|
23
|
-
getLeftVisibleCells: () => Cell<TGenerics>[]
|
|
24
|
-
getCenterVisibleCells: () => Cell<TGenerics>[]
|
|
25
|
-
getRightVisibleCells: () => Cell<TGenerics>[]
|
|
26
|
-
}
|
|
27
18
|
|
|
28
19
|
export type HeadersInstance<TGenerics extends TableGenerics> = {
|
|
29
20
|
createHeader: (
|
|
@@ -32,6 +23,7 @@ export type HeadersInstance<TGenerics extends TableGenerics> = {
|
|
|
32
23
|
id?: string
|
|
33
24
|
isPlaceholder?: boolean
|
|
34
25
|
placeholderId?: string
|
|
26
|
+
index: number
|
|
35
27
|
depth: number
|
|
36
28
|
}
|
|
37
29
|
) => Header<TGenerics>
|
|
@@ -73,100 +65,12 @@ export type HeadersInstance<TGenerics extends TableGenerics> = {
|
|
|
73
65
|
headerId: string,
|
|
74
66
|
userProps?: TGetter
|
|
75
67
|
) => undefined | PropGetterValue<FooterProps, TGetter>
|
|
76
|
-
getTotalWidth: () => number
|
|
77
68
|
}
|
|
78
69
|
|
|
79
70
|
//
|
|
80
71
|
|
|
81
72
|
export const Headers = {
|
|
82
|
-
|
|
83
|
-
row: Row<TGenerics>,
|
|
84
|
-
instance: TableInstance<TGenerics>
|
|
85
|
-
): HeadersRow<TGenerics> => {
|
|
86
|
-
return {
|
|
87
|
-
_getAllVisibleCells: memo(
|
|
88
|
-
() => [
|
|
89
|
-
row
|
|
90
|
-
.getAllCells()
|
|
91
|
-
.filter(cell => cell.column.getIsVisible())
|
|
92
|
-
.map(d => d.id)
|
|
93
|
-
.join('_'),
|
|
94
|
-
],
|
|
95
|
-
_ => {
|
|
96
|
-
return row.getAllCells().filter(cell => cell.column.getIsVisible())
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: 'row._getAllVisibleCells',
|
|
100
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
101
|
-
}
|
|
102
|
-
),
|
|
103
|
-
getVisibleCells: memo(
|
|
104
|
-
() => [
|
|
105
|
-
row.getLeftVisibleCells(),
|
|
106
|
-
row.getCenterVisibleCells(),
|
|
107
|
-
row.getRightVisibleCells(),
|
|
108
|
-
],
|
|
109
|
-
(left, center, right) => [...left, ...center, ...right],
|
|
110
|
-
{
|
|
111
|
-
key: 'row.getVisibleCells',
|
|
112
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
113
|
-
}
|
|
114
|
-
),
|
|
115
|
-
getCenterVisibleCells: memo(
|
|
116
|
-
() => [
|
|
117
|
-
row._getAllVisibleCells(),
|
|
118
|
-
instance.getState().columnPinning.left,
|
|
119
|
-
instance.getState().columnPinning.right,
|
|
120
|
-
],
|
|
121
|
-
(allCells, left, right) => {
|
|
122
|
-
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
|
|
123
|
-
|
|
124
|
-
return allCells.filter(d => !leftAndRight.includes(d.columnId))
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
key: 'row.getCenterVisibleCells',
|
|
128
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
129
|
-
}
|
|
130
|
-
),
|
|
131
|
-
getLeftVisibleCells: memo(
|
|
132
|
-
() => [
|
|
133
|
-
row._getAllVisibleCells(),
|
|
134
|
-
instance.getState().columnPinning.left,
|
|
135
|
-
,
|
|
136
|
-
],
|
|
137
|
-
(allCells, left) => {
|
|
138
|
-
const cells = (left ?? [])
|
|
139
|
-
.map(columnId => allCells.find(cell => cell.columnId === columnId)!)
|
|
140
|
-
.filter(Boolean)
|
|
141
|
-
|
|
142
|
-
return cells
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
key: 'row.getLeftVisibleCells',
|
|
146
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
147
|
-
}
|
|
148
|
-
),
|
|
149
|
-
getRightVisibleCells: memo(
|
|
150
|
-
() => [
|
|
151
|
-
row._getAllVisibleCells(),
|
|
152
|
-
instance.getState().columnPinning.right,
|
|
153
|
-
],
|
|
154
|
-
(allCells, right) => {
|
|
155
|
-
const cells = (right ?? [])
|
|
156
|
-
.map(columnId => allCells.find(cell => cell.columnId === columnId)!)
|
|
157
|
-
.filter(Boolean)
|
|
158
|
-
|
|
159
|
-
return cells
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
key: 'row.getRightVisibleCells',
|
|
163
|
-
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
164
|
-
}
|
|
165
|
-
),
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
getInstance: <TGenerics extends TableGenerics>(
|
|
73
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
170
74
|
instance: TableInstance<TGenerics>
|
|
171
75
|
): HeadersInstance<TGenerics> => {
|
|
172
76
|
return {
|
|
@@ -176,6 +80,7 @@ export const Headers = {
|
|
|
176
80
|
id?: string
|
|
177
81
|
isPlaceholder?: boolean
|
|
178
82
|
placeholderId?: string
|
|
83
|
+
index: number
|
|
179
84
|
depth: number
|
|
180
85
|
}
|
|
181
86
|
) => {
|
|
@@ -184,20 +89,22 @@ export const Headers = {
|
|
|
184
89
|
let header: CoreHeader<TGenerics> = {
|
|
185
90
|
id,
|
|
186
91
|
column,
|
|
92
|
+
index: options.index,
|
|
187
93
|
isPlaceholder: options.isPlaceholder,
|
|
188
94
|
placeholderId: options.placeholderId,
|
|
189
95
|
depth: options.depth,
|
|
190
96
|
subHeaders: [],
|
|
191
97
|
colSpan: 0,
|
|
192
98
|
rowSpan: 0,
|
|
193
|
-
|
|
99
|
+
headerGroup: null!,
|
|
100
|
+
getSize: () => {
|
|
194
101
|
let sum = 0
|
|
195
102
|
|
|
196
103
|
const recurse = (header: CoreHeader<TGenerics>) => {
|
|
197
104
|
if (header.subHeaders.length) {
|
|
198
105
|
header.subHeaders.forEach(recurse)
|
|
199
106
|
} else {
|
|
200
|
-
sum += header.column.
|
|
107
|
+
sum += header.column.getSize() ?? 0
|
|
201
108
|
}
|
|
202
109
|
}
|
|
203
110
|
|
|
@@ -205,6 +112,15 @@ export const Headers = {
|
|
|
205
112
|
|
|
206
113
|
return sum
|
|
207
114
|
},
|
|
115
|
+
getStart: () => {
|
|
116
|
+
if (header.index > 0) {
|
|
117
|
+
const prevSiblingHeader =
|
|
118
|
+
header.headerGroup.headers[header.index - 1]
|
|
119
|
+
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return 0
|
|
123
|
+
},
|
|
208
124
|
getLeafHeaders: (): Header<TGenerics>[] => {
|
|
209
125
|
const leafHeaders: CoreHeader<TGenerics>[] = []
|
|
210
126
|
|
|
@@ -241,11 +157,11 @@ export const Headers = {
|
|
|
241
157
|
: null,
|
|
242
158
|
}
|
|
243
159
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
160
|
+
instance._features.forEach(feature => {
|
|
161
|
+
Object.assign(header, feature.createHeader?.(header, instance))
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
return header as Header<TGenerics>
|
|
249
165
|
},
|
|
250
166
|
|
|
251
167
|
// Header Groups
|
|
@@ -592,16 +508,6 @@ export const Headers = {
|
|
|
592
508
|
|
|
593
509
|
return propGetter(initialProps, userProps)
|
|
594
510
|
},
|
|
595
|
-
|
|
596
|
-
getTotalWidth: () => {
|
|
597
|
-
let width = 0
|
|
598
|
-
|
|
599
|
-
instance.getVisibleLeafColumns().forEach(column => {
|
|
600
|
-
width += column.getWidth() ?? 0
|
|
601
|
-
})
|
|
602
|
-
|
|
603
|
-
return width
|
|
604
|
-
},
|
|
605
511
|
}
|
|
606
512
|
},
|
|
607
513
|
}
|
|
@@ -652,13 +558,13 @@ export function buildHeaderGroups<TGenerics extends TableGenerics>(
|
|
|
652
558
|
}
|
|
653
559
|
|
|
654
560
|
// The parent columns we're going to scan next
|
|
655
|
-
const
|
|
561
|
+
const pendingParentHeaders: Header<TGenerics>[] = []
|
|
656
562
|
|
|
657
563
|
// Scan each column for parents
|
|
658
564
|
headersToGroup.forEach(headerToGroup => {
|
|
659
565
|
// What is the latest (last) parent column?
|
|
660
566
|
|
|
661
|
-
const
|
|
567
|
+
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0]
|
|
662
568
|
|
|
663
569
|
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth
|
|
664
570
|
|
|
@@ -674,41 +580,45 @@ export function buildHeaderGroups<TGenerics extends TableGenerics>(
|
|
|
674
580
|
isPlaceholder = true
|
|
675
581
|
}
|
|
676
582
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
.join('_'),
|
|
681
|
-
isPlaceholder,
|
|
682
|
-
placeholderId: isPlaceholder
|
|
683
|
-
? `${parentHeaders.filter(d => d.column === column).length}`
|
|
684
|
-
: undefined,
|
|
685
|
-
depth,
|
|
686
|
-
})
|
|
687
|
-
|
|
688
|
-
if (!latestParentHeader || latestParentHeader.column !== header.column) {
|
|
689
|
-
header.subHeaders.push(headerToGroup)
|
|
690
|
-
parentHeaders.push(header)
|
|
583
|
+
if (latestPendingParentHeader?.column === column) {
|
|
584
|
+
// This column is repeated. Add it as a sub header to the next batch
|
|
585
|
+
latestPendingParentHeader.subHeaders.push(headerToGroup)
|
|
691
586
|
} else {
|
|
692
|
-
|
|
693
|
-
|
|
587
|
+
// This is a new header. Let's create it
|
|
588
|
+
const header = instance.createHeader(column, {
|
|
589
|
+
id: [headerFamily, depth, column.id, headerToGroup?.id]
|
|
590
|
+
.filter(Boolean)
|
|
591
|
+
.join('_'),
|
|
592
|
+
isPlaceholder,
|
|
593
|
+
placeholderId: isPlaceholder
|
|
594
|
+
? `${pendingParentHeaders.filter(d => d.column === column).length}`
|
|
595
|
+
: undefined,
|
|
596
|
+
depth,
|
|
597
|
+
index: pendingParentHeaders.length,
|
|
598
|
+
})
|
|
694
599
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
600
|
+
// Add the headerToGroup as a subHeader of the new header
|
|
601
|
+
header.subHeaders.push(headerToGroup)
|
|
602
|
+
// Add the new header to the pendingParentHeaders to get grouped
|
|
603
|
+
// in the next batch
|
|
604
|
+
pendingParentHeaders.push(header)
|
|
605
|
+
}
|
|
698
606
|
|
|
699
607
|
headerGroup.headers.push(headerToGroup)
|
|
608
|
+
headerToGroup.headerGroup = headerGroup
|
|
700
609
|
})
|
|
701
610
|
|
|
702
611
|
headerGroups.push(headerGroup)
|
|
703
612
|
|
|
704
613
|
if (depth > 0) {
|
|
705
|
-
createHeaderGroup(
|
|
614
|
+
createHeaderGroup(pendingParentHeaders, depth - 1)
|
|
706
615
|
}
|
|
707
616
|
}
|
|
708
617
|
|
|
709
|
-
const bottomHeaders = columnsToGroup.map(column =>
|
|
618
|
+
const bottomHeaders = columnsToGroup.map((column, index) =>
|
|
710
619
|
instance.createHeader(column, {
|
|
711
620
|
depth: maxDepth,
|
|
621
|
+
index,
|
|
712
622
|
})
|
|
713
623
|
)
|
|
714
624
|
|
package/src/features/Ordering.ts
CHANGED
package/src/features/Pinning.ts
CHANGED
|
@@ -4,10 +4,12 @@ import {
|
|
|
4
4
|
TableInstance,
|
|
5
5
|
Column,
|
|
6
6
|
TableGenerics,
|
|
7
|
+
Row,
|
|
8
|
+
Cell,
|
|
7
9
|
} from '../types'
|
|
8
|
-
import { functionalUpdate, makeStateUpdater } from '../utils'
|
|
10
|
+
import { functionalUpdate, makeStateUpdater, memo } from '../utils'
|
|
9
11
|
|
|
10
|
-
type ColumnPinningPosition = false | 'left' | 'right'
|
|
12
|
+
export type ColumnPinningPosition = false | 'left' | 'right'
|
|
11
13
|
|
|
12
14
|
export type ColumnPinningState = {
|
|
13
15
|
left?: string[]
|
|
@@ -39,6 +41,18 @@ export type ColumnPinningColumn = {
|
|
|
39
41
|
pin: (position: ColumnPinningPosition) => void
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
export type ColumnPinningRow<TGenerics extends TableGenerics> = {
|
|
45
|
+
getLeftVisibleCells: () => Cell<TGenerics>[]
|
|
46
|
+
getCenterVisibleCells: () => Cell<TGenerics>[]
|
|
47
|
+
getRightVisibleCells: () => Cell<TGenerics>[]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ColumnPinningCell<TGenerics extends TableGenerics> = {
|
|
51
|
+
getLeftVisibleCells: () => Cell<TGenerics>[]
|
|
52
|
+
getCenterVisibleCells: () => Cell<TGenerics>[]
|
|
53
|
+
getRightVisibleCells: () => Cell<TGenerics>[]
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
export type ColumnPinningInstance<TGenerics extends TableGenerics> = {
|
|
43
57
|
setColumnPinning: (updater: Updater<ColumnPinningState>) => void
|
|
44
58
|
resetColumnPinning: () => void
|
|
@@ -47,6 +61,9 @@ export type ColumnPinningInstance<TGenerics extends TableGenerics> = {
|
|
|
47
61
|
getColumnIsPinned: (columnId: string) => ColumnPinningPosition
|
|
48
62
|
getColumnPinnedIndex: (columnId: string) => number
|
|
49
63
|
getIsSomeColumnsPinned: () => boolean
|
|
64
|
+
getLeftLeafColumns: () => Column<TGenerics>[]
|
|
65
|
+
getRightLeafColumns: () => Column<TGenerics>[]
|
|
66
|
+
getCenterLeafColumns: () => Column<TGenerics>[]
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
//
|
|
@@ -81,7 +98,129 @@ export const Pinning = {
|
|
|
81
98
|
}
|
|
82
99
|
},
|
|
83
100
|
|
|
84
|
-
|
|
101
|
+
createRow: <TGenerics extends TableGenerics>(
|
|
102
|
+
row: Row<TGenerics>,
|
|
103
|
+
instance: TableInstance<TGenerics>
|
|
104
|
+
): ColumnPinningRow<TGenerics> => {
|
|
105
|
+
return {
|
|
106
|
+
getCenterVisibleCells: memo(
|
|
107
|
+
() => [
|
|
108
|
+
row._getAllVisibleCells(),
|
|
109
|
+
instance.getState().columnPinning.left,
|
|
110
|
+
instance.getState().columnPinning.right,
|
|
111
|
+
],
|
|
112
|
+
(allCells, left, right) => {
|
|
113
|
+
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
|
|
114
|
+
|
|
115
|
+
return allCells.filter(d => !leftAndRight.includes(d.columnId))
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: 'row.getCenterVisibleCells',
|
|
119
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
getLeftVisibleCells: memo(
|
|
123
|
+
() => [
|
|
124
|
+
row._getAllVisibleCells(),
|
|
125
|
+
instance.getState().columnPinning.left,
|
|
126
|
+
,
|
|
127
|
+
],
|
|
128
|
+
(allCells, left) => {
|
|
129
|
+
const cells = (left ?? [])
|
|
130
|
+
.map(columnId => allCells.find(cell => cell.columnId === columnId)!)
|
|
131
|
+
.filter(Boolean)
|
|
132
|
+
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>))
|
|
133
|
+
|
|
134
|
+
return cells
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: 'row.getLeftVisibleCells',
|
|
138
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
getRightVisibleCells: memo(
|
|
142
|
+
() => [
|
|
143
|
+
row._getAllVisibleCells(),
|
|
144
|
+
instance.getState().columnPinning.right,
|
|
145
|
+
],
|
|
146
|
+
(allCells, right) => {
|
|
147
|
+
const cells = (right ?? [])
|
|
148
|
+
.map(columnId => allCells.find(cell => cell.columnId === columnId)!)
|
|
149
|
+
.filter(Boolean)
|
|
150
|
+
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>))
|
|
151
|
+
|
|
152
|
+
return cells
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: 'row.getRightVisibleCells',
|
|
156
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
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',
|
|
217
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
85
224
|
instance: TableInstance<TGenerics>
|
|
86
225
|
): ColumnPinningInstance<TGenerics> => {
|
|
87
226
|
return {
|
|
@@ -176,6 +315,58 @@ export const Pinning = {
|
|
|
176
315
|
|
|
177
316
|
return Boolean(left?.length || right?.length)
|
|
178
317
|
},
|
|
318
|
+
|
|
319
|
+
getLeftLeafColumns: memo(
|
|
320
|
+
() => [
|
|
321
|
+
instance.getAllLeafColumns(),
|
|
322
|
+
instance.getState().columnPinning.left,
|
|
323
|
+
],
|
|
324
|
+
(allColumns, left) => {
|
|
325
|
+
return (left ?? [])
|
|
326
|
+
.map(columnId => allColumns.find(column => column.id === columnId)!)
|
|
327
|
+
.filter(Boolean)
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
key: 'getLeftLeafColumns',
|
|
331
|
+
debug: () =>
|
|
332
|
+
instance.options.debugAll ?? instance.options.debugColumns,
|
|
333
|
+
}
|
|
334
|
+
),
|
|
335
|
+
|
|
336
|
+
getRightLeafColumns: memo(
|
|
337
|
+
() => [
|
|
338
|
+
instance.getAllLeafColumns(),
|
|
339
|
+
instance.getState().columnPinning.right,
|
|
340
|
+
],
|
|
341
|
+
(allColumns, right) => {
|
|
342
|
+
return (right ?? [])
|
|
343
|
+
.map(columnId => allColumns.find(column => column.id === columnId)!)
|
|
344
|
+
.filter(Boolean)
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
key: 'getRightLeafColumns',
|
|
348
|
+
debug: () =>
|
|
349
|
+
instance.options.debugAll ?? instance.options.debugColumns,
|
|
350
|
+
}
|
|
351
|
+
),
|
|
352
|
+
|
|
353
|
+
getCenterLeafColumns: memo(
|
|
354
|
+
() => [
|
|
355
|
+
instance.getAllLeafColumns(),
|
|
356
|
+
instance.getState().columnPinning.left,
|
|
357
|
+
instance.getState().columnPinning.right,
|
|
358
|
+
],
|
|
359
|
+
(allColumns, left, right) => {
|
|
360
|
+
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
|
|
361
|
+
|
|
362
|
+
return allColumns.filter(d => !leftAndRight.includes(d.id))
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
key: 'getCenterLeafColumns',
|
|
366
|
+
debug: () =>
|
|
367
|
+
instance.options.debugAll ?? instance.options.debugColumns,
|
|
368
|
+
}
|
|
369
|
+
),
|
|
179
370
|
}
|
|
180
371
|
},
|
|
181
372
|
}
|
|
@@ -120,7 +120,7 @@ export const RowSelection = {
|
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
124
124
|
instance: TableInstance<TGenerics>
|
|
125
125
|
): RowSelectionInstance<TGenerics> => {
|
|
126
126
|
let registered = false
|