@tanstack/table-core 9.0.0-beta.37 → 9.0.0-beta.38
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/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.d.cts +1 -1
- package/dist/core/headers/buildHeaderGroups.d.ts +1 -1
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs +7 -7
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.js +7 -7
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +5 -5
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +5 -5
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +3 -3
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +3 -3
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +44 -39
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.d.cts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.d.ts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.js +45 -40
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +49 -38
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +49 -38
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +154 -146
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +81 -73
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +81 -73
- package/dist/features/column-pinning/columnPinningFeature.utils.js +141 -133
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +4 -4
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +5 -5
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +18 -12
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +18 -12
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +24 -20
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +18 -14
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +18 -14
- package/dist/features/column-sizing/columnSizingFeature.utils.js +24 -20
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +16 -16
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +16 -16
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/static-functions.cjs +16 -16
- package/dist/static-functions.d.cts +3 -3
- package/dist/static-functions.d.ts +3 -3
- package/dist/static-functions.js +3 -3
- package/package.json +1 -1
- package/src/core/headers/buildHeaderGroups.ts +1 -1
- package/src/core/headers/coreHeadersFeature.utils.ts +7 -7
- package/src/features/column-ordering/columnOrderingFeature.types.ts +5 -5
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +9 -9
- package/src/features/column-pinning/columnPinningFeature.ts +64 -59
- package/src/features/column-pinning/columnPinningFeature.types.ts +49 -38
- package/src/features/column-pinning/columnPinningFeature.utils.ts +163 -155
- package/src/features/column-sizing/columnSizingFeature.ts +6 -6
- package/src/features/column-sizing/columnSizingFeature.types.ts +18 -12
- package/src/features/column-sizing/columnSizingFeature.utils.ts +31 -27
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +15 -15
|
@@ -34,8 +34,8 @@ import type {
|
|
|
34
34
|
*/
|
|
35
35
|
export function getDefaultColumnPinningState(): ColumnPinningState {
|
|
36
36
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
start: [],
|
|
38
|
+
end: [],
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -45,12 +45,16 @@ export function getDefaultColumnPinningState(): ColumnPinningState {
|
|
|
45
45
|
* Moves this column's leaf column ids into a pinning region.
|
|
46
46
|
*
|
|
47
47
|
* Pinning a group column pins all of its leaves. The leaf ids are first removed
|
|
48
|
-
* from both regions, then appended to the requested `'
|
|
48
|
+
* from both regions, then appended to the requested `'start'` or `'end'`
|
|
49
49
|
* region. Passing `false` unpins them back to the center.
|
|
50
50
|
*
|
|
51
|
+
* `start` and `end` are logical positions. In LTR languages/layouts, `start`
|
|
52
|
+
* usually corresponds to left and `end` to right. In RTL languages/layouts,
|
|
53
|
+
* `start` usually corresponds to right and `end` to left.
|
|
54
|
+
*
|
|
51
55
|
* @example
|
|
52
56
|
* ```ts
|
|
53
|
-
* column_pin(column, '
|
|
57
|
+
* column_pin(column, 'start')
|
|
54
58
|
* ```
|
|
55
59
|
*/
|
|
56
60
|
export function column_pin<
|
|
@@ -70,26 +74,26 @@ export function column_pin<
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
table_setColumnPinning(column.table, (old) => {
|
|
73
|
-
if (position === '
|
|
77
|
+
if (position === 'end') {
|
|
74
78
|
return {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...old.right.filter((d) => !columnIds.includes(d)),
|
|
78
|
-
...columnIds,
|
|
79
|
-
],
|
|
79
|
+
start: old.start.filter((d) => !columnIds.includes(d)),
|
|
80
|
+
end: [...old.end.filter((d) => !columnIds.includes(d)), ...columnIds],
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
if (position === '
|
|
84
|
+
if (position === 'start') {
|
|
84
85
|
return {
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
start: [
|
|
87
|
+
...old.start.filter((d) => !columnIds.includes(d)),
|
|
88
|
+
...columnIds,
|
|
89
|
+
],
|
|
90
|
+
end: old.end.filter((d) => !columnIds.includes(d)),
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
return {
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
start: old.start.filter((d) => !columnIds.includes(d)),
|
|
96
|
+
end: old.end.filter((d) => !columnIds.includes(d)),
|
|
93
97
|
}
|
|
94
98
|
})
|
|
95
99
|
}
|
|
@@ -124,9 +128,13 @@ export function column_getCanPin<
|
|
|
124
128
|
/**
|
|
125
129
|
* Reads this column's current pinning region.
|
|
126
130
|
*
|
|
127
|
-
* Group columns report `'
|
|
131
|
+
* Group columns report `'start'` or `'end'` when any leaf column is pinned in
|
|
128
132
|
* that region. Unpinned columns return `false`.
|
|
129
133
|
*
|
|
134
|
+
* `start` and `end` are logical positions. In LTR languages/layouts, `start`
|
|
135
|
+
* usually corresponds to left and `end` to right. In RTL languages/layouts,
|
|
136
|
+
* `start` usually corresponds to right and `end` to left.
|
|
137
|
+
*
|
|
130
138
|
* @example
|
|
131
139
|
* ```ts
|
|
132
140
|
* const position = column_getIsPinned(column)
|
|
@@ -141,17 +149,17 @@ export function column_getIsPinned<
|
|
|
141
149
|
): ColumnPinningPosition | false {
|
|
142
150
|
const leafColumns = column.getLeafColumns()
|
|
143
151
|
|
|
144
|
-
const {
|
|
152
|
+
const { start, end } =
|
|
145
153
|
column.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
146
154
|
|
|
147
155
|
for (let i = 0; i < leafColumns.length; i++) {
|
|
148
|
-
if (
|
|
149
|
-
return '
|
|
156
|
+
if (start.includes(leafColumns[i]!.id)) {
|
|
157
|
+
return 'start'
|
|
150
158
|
}
|
|
151
159
|
}
|
|
152
160
|
for (let i = 0; i < leafColumns.length; i++) {
|
|
153
|
-
if (
|
|
154
|
-
return '
|
|
161
|
+
if (end.includes(leafColumns[i]!.id)) {
|
|
162
|
+
return 'end'
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
165
|
return false
|
|
@@ -161,7 +169,7 @@ export function column_getIsPinned<
|
|
|
161
169
|
* Finds this column's index within its pinned region.
|
|
162
170
|
*
|
|
163
171
|
* Unpinned columns return `0`; pinned columns return their position in
|
|
164
|
-
* `state.columnPinning.
|
|
172
|
+
* `state.columnPinning.start` or `state.columnPinning.end`.
|
|
165
173
|
*
|
|
166
174
|
* @example
|
|
167
175
|
* ```ts
|
|
@@ -184,7 +192,7 @@ export function column_getPinnedIndex<
|
|
|
184
192
|
// Row APIs
|
|
185
193
|
|
|
186
194
|
/**
|
|
187
|
-
* Collects visible cells whose columns are not pinned
|
|
195
|
+
* Collects visible cells whose columns are not pinned start or end.
|
|
188
196
|
*
|
|
189
197
|
* The result preserves the row's visible-cell order for center columns.
|
|
190
198
|
*
|
|
@@ -202,45 +210,45 @@ export function row_getCenterVisibleCells<
|
|
|
202
210
|
'getVisibleCells',
|
|
203
211
|
row_getVisibleCells,
|
|
204
212
|
)
|
|
205
|
-
const {
|
|
213
|
+
const { start, end } =
|
|
206
214
|
row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
207
|
-
if (!
|
|
215
|
+
if (!start.length && !end.length) {
|
|
208
216
|
return allCells
|
|
209
217
|
}
|
|
210
|
-
const
|
|
211
|
-
return allCells.filter((d) => !
|
|
218
|
+
const startAndEnd: Array<string> = [...start, ...end]
|
|
219
|
+
return allCells.filter((d) => !startAndEnd.includes(d.column.id))
|
|
212
220
|
}
|
|
213
221
|
|
|
214
222
|
/**
|
|
215
|
-
* Collects visible cells for columns pinned to the
|
|
223
|
+
* Collects visible cells for columns pinned to the start region.
|
|
216
224
|
*
|
|
217
|
-
* Cells are returned in `state.columnPinning.
|
|
218
|
-
* `cell.position = '
|
|
225
|
+
* Cells are returned in `state.columnPinning.start` order and are marked with
|
|
226
|
+
* `cell.position = 'start'`.
|
|
219
227
|
*
|
|
220
228
|
* @example
|
|
221
229
|
* ```ts
|
|
222
|
-
* const
|
|
230
|
+
* const startCells = row_getStartVisibleCells(row)
|
|
223
231
|
* ```
|
|
224
232
|
*/
|
|
225
|
-
export function
|
|
233
|
+
export function row_getStartVisibleCells<
|
|
226
234
|
TFeatures extends TableFeatures,
|
|
227
235
|
TData extends RowData,
|
|
228
236
|
>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {
|
|
229
|
-
const {
|
|
237
|
+
const { start } =
|
|
230
238
|
row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
231
|
-
if (!
|
|
239
|
+
if (!start.length) return []
|
|
232
240
|
const allVisibleCells = callMemoOrStaticFn(
|
|
233
241
|
row,
|
|
234
242
|
'getVisibleCellsByColumnId',
|
|
235
243
|
row_getVisibleCellsByColumnId,
|
|
236
244
|
)
|
|
237
245
|
const cells: Array<Cell<TFeatures, TData, unknown>> = []
|
|
238
|
-
for (let i = 0; i <
|
|
239
|
-
const columnId =
|
|
246
|
+
for (let i = 0; i < start.length; i++) {
|
|
247
|
+
const columnId = start[i]!
|
|
240
248
|
const cell = allVisibleCells[columnId]
|
|
241
249
|
if (cell) {
|
|
242
250
|
// Assign position property directly to preserve prototype chain
|
|
243
|
-
;(cell as any).position = '
|
|
251
|
+
;(cell as any).position = 'start'
|
|
244
252
|
cells.push(cell)
|
|
245
253
|
}
|
|
246
254
|
}
|
|
@@ -248,35 +256,35 @@ export function row_getLeftVisibleCells<
|
|
|
248
256
|
}
|
|
249
257
|
|
|
250
258
|
/**
|
|
251
|
-
* Collects visible cells for columns pinned to the
|
|
259
|
+
* Collects visible cells for columns pinned to the end region.
|
|
252
260
|
*
|
|
253
|
-
* Cells are returned in `state.columnPinning.
|
|
254
|
-
* `cell.position = '
|
|
261
|
+
* Cells are returned in `state.columnPinning.end` order and are marked with
|
|
262
|
+
* `cell.position = 'end'`.
|
|
255
263
|
*
|
|
256
264
|
* @example
|
|
257
265
|
* ```ts
|
|
258
|
-
* const
|
|
266
|
+
* const endCells = row_getEndVisibleCells(row)
|
|
259
267
|
* ```
|
|
260
268
|
*/
|
|
261
|
-
export function
|
|
269
|
+
export function row_getEndVisibleCells<
|
|
262
270
|
TFeatures extends TableFeatures,
|
|
263
271
|
TData extends RowData,
|
|
264
272
|
>(row: Row<TFeatures, TData>) {
|
|
265
|
-
const {
|
|
273
|
+
const { end } =
|
|
266
274
|
row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
267
|
-
if (!
|
|
275
|
+
if (!end.length) return [] as Array<Cell<TFeatures, TData, unknown>>
|
|
268
276
|
const allVisibleCells = callMemoOrStaticFn(
|
|
269
277
|
row,
|
|
270
278
|
'getVisibleCellsByColumnId',
|
|
271
279
|
row_getVisibleCellsByColumnId,
|
|
272
280
|
)
|
|
273
281
|
const cells: Array<Cell<TFeatures, TData, unknown>> = []
|
|
274
|
-
for (let i = 0; i <
|
|
275
|
-
const columnId =
|
|
282
|
+
for (let i = 0; i < end.length; i++) {
|
|
283
|
+
const columnId = end[i]!
|
|
276
284
|
const cell = allVisibleCells[columnId]
|
|
277
285
|
if (cell) {
|
|
278
286
|
// Assign position property directly to preserve prototype chain
|
|
279
|
-
;(cell as any).position = '
|
|
287
|
+
;(cell as any).position = 'end'
|
|
280
288
|
cells.push(cell)
|
|
281
289
|
}
|
|
282
290
|
}
|
|
@@ -288,12 +296,12 @@ export function row_getRightVisibleCells<
|
|
|
288
296
|
/**
|
|
289
297
|
* Routes a column pinning updater through the table's pinning change handler.
|
|
290
298
|
*
|
|
291
|
-
* The updater may be a next `{
|
|
299
|
+
* The updater may be a next `{ start, end }` state or a function of the
|
|
292
300
|
* previous state, matching the instance `table.setColumnPinning` behavior.
|
|
293
301
|
*
|
|
294
302
|
* @example
|
|
295
303
|
* ```ts
|
|
296
|
-
* table_setColumnPinning(table, (old) => ({ ...old,
|
|
304
|
+
* table_setColumnPinning(table, (old) => ({ ...old, start: ['select'] }))
|
|
297
305
|
* ```
|
|
298
306
|
*/
|
|
299
307
|
export function table_setColumnPinning<
|
|
@@ -310,7 +318,7 @@ export function table_setColumnPinning<
|
|
|
310
318
|
* Resets `columnPinning` to the configured initial state or feature default.
|
|
311
319
|
*
|
|
312
320
|
* With no argument, the reset clones `table.initialState.columnPinning` when it
|
|
313
|
-
* exists. Passing `true` ignores initial state and resets to empty
|
|
321
|
+
* exists. Passing `true` ignores initial state and resets to empty start/end
|
|
314
322
|
* arrays.
|
|
315
323
|
*
|
|
316
324
|
* @example
|
|
@@ -336,7 +344,7 @@ export function table_resetColumnPinning<
|
|
|
336
344
|
/**
|
|
337
345
|
* Checks whether any columns are pinned.
|
|
338
346
|
*
|
|
339
|
-
* Omit `position` to check both sides, or pass `'
|
|
347
|
+
* Omit `position` to check both sides, or pass `'start'`/`'end'` to inspect a
|
|
340
348
|
* single pinning region.
|
|
341
349
|
*
|
|
342
350
|
* @example
|
|
@@ -351,7 +359,7 @@ export function table_getIsSomeColumnsPinned<
|
|
|
351
359
|
const pinningState = table.atoms.columnPinning?.get()
|
|
352
360
|
|
|
353
361
|
if (!position) {
|
|
354
|
-
return Boolean(pinningState?.
|
|
362
|
+
return Boolean(pinningState?.start.length || pinningState?.end.length)
|
|
355
363
|
}
|
|
356
364
|
return Boolean(pinningState?.[position].length)
|
|
357
365
|
}
|
|
@@ -359,28 +367,28 @@ export function table_getIsSomeColumnsPinned<
|
|
|
359
367
|
// header groups
|
|
360
368
|
|
|
361
369
|
/**
|
|
362
|
-
* Builds header groups for visible columns pinned to the
|
|
370
|
+
* Builds header groups for visible columns pinned to the start region.
|
|
363
371
|
*
|
|
364
|
-
* The leaf columns are read in `state.columnPinning.
|
|
372
|
+
* The leaf columns are read in `state.columnPinning.start` order and then passed
|
|
365
373
|
* through the same header-group builder as the unpinned table.
|
|
366
374
|
*
|
|
367
375
|
* @example
|
|
368
376
|
* ```ts
|
|
369
|
-
* const headerGroups =
|
|
377
|
+
* const headerGroups = table_getStartHeaderGroups(table)
|
|
370
378
|
* ```
|
|
371
379
|
*/
|
|
372
|
-
export function
|
|
380
|
+
export function table_getStartHeaderGroups<
|
|
373
381
|
TFeatures extends TableFeatures,
|
|
374
382
|
TData extends RowData,
|
|
375
383
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
376
384
|
const allColumns = table.getAllColumns()
|
|
377
385
|
const leafColumnsById = table.getAllLeafColumnsById()
|
|
378
|
-
const {
|
|
386
|
+
const { start } =
|
|
379
387
|
table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
380
388
|
|
|
381
389
|
const orderedLeafColumns: Array<Column<TFeatures, TData, unknown>> = []
|
|
382
|
-
for (let i = 0; i <
|
|
383
|
-
const column = leafColumnsById[
|
|
390
|
+
for (let i = 0; i < start.length; i++) {
|
|
391
|
+
const column = leafColumnsById[start[i]!]
|
|
384
392
|
if (
|
|
385
393
|
column &&
|
|
386
394
|
callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)
|
|
@@ -389,32 +397,32 @@ export function table_getLeftHeaderGroups<
|
|
|
389
397
|
}
|
|
390
398
|
}
|
|
391
399
|
|
|
392
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, table, '
|
|
400
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'start')
|
|
393
401
|
}
|
|
394
402
|
|
|
395
403
|
/**
|
|
396
|
-
* Builds header groups for visible columns pinned to the
|
|
404
|
+
* Builds header groups for visible columns pinned to the end region.
|
|
397
405
|
*
|
|
398
|
-
* The leaf columns are read in `state.columnPinning.
|
|
406
|
+
* The leaf columns are read in `state.columnPinning.end` order and then
|
|
399
407
|
* passed through the same header-group builder as the unpinned table.
|
|
400
408
|
*
|
|
401
409
|
* @example
|
|
402
410
|
* ```ts
|
|
403
|
-
* const headerGroups =
|
|
411
|
+
* const headerGroups = table_getEndHeaderGroups(table)
|
|
404
412
|
* ```
|
|
405
413
|
*/
|
|
406
|
-
export function
|
|
414
|
+
export function table_getEndHeaderGroups<
|
|
407
415
|
TFeatures extends TableFeatures,
|
|
408
416
|
TData extends RowData,
|
|
409
417
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
410
418
|
const allColumns = table.getAllColumns()
|
|
411
419
|
const leafColumnsById = table.getAllLeafColumnsById()
|
|
412
|
-
const {
|
|
420
|
+
const { end } =
|
|
413
421
|
table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
414
422
|
|
|
415
423
|
const orderedLeafColumns: Array<Column<TFeatures, TData, unknown>> = []
|
|
416
|
-
for (let i = 0; i <
|
|
417
|
-
const column = leafColumnsById[
|
|
424
|
+
for (let i = 0; i < end.length; i++) {
|
|
425
|
+
const column = leafColumnsById[end[i]!]
|
|
418
426
|
if (
|
|
419
427
|
column &&
|
|
420
428
|
callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)
|
|
@@ -423,13 +431,13 @@ export function table_getRightHeaderGroups<
|
|
|
423
431
|
}
|
|
424
432
|
}
|
|
425
433
|
|
|
426
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, table, '
|
|
434
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'end')
|
|
427
435
|
}
|
|
428
436
|
|
|
429
437
|
/**
|
|
430
438
|
* Builds header groups for visible columns that are not pinned.
|
|
431
439
|
*
|
|
432
|
-
*
|
|
440
|
+
* Start- and end-pinned column ids are removed from the visible leaf column
|
|
433
441
|
* list before header groups are built for the center region.
|
|
434
442
|
*
|
|
435
443
|
* @example
|
|
@@ -449,12 +457,12 @@ export function table_getCenterHeaderGroups<
|
|
|
449
457
|
'getVisibleLeafColumns',
|
|
450
458
|
table_getVisibleLeafColumns,
|
|
451
459
|
)
|
|
452
|
-
const {
|
|
460
|
+
const { start, end } =
|
|
453
461
|
table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
462
|
+
if (start.length || end.length) {
|
|
463
|
+
const startAndEnd: Array<string> = [...start, ...end]
|
|
456
464
|
leafColumns = leafColumns.filter(
|
|
457
|
-
(column) => !
|
|
465
|
+
(column) => !startAndEnd.includes(column.id),
|
|
458
466
|
)
|
|
459
467
|
}
|
|
460
468
|
return buildHeaderGroups(allColumns, leafColumns, table, 'center')
|
|
@@ -463,45 +471,45 @@ export function table_getCenterHeaderGroups<
|
|
|
463
471
|
// footer groups
|
|
464
472
|
|
|
465
473
|
/**
|
|
466
|
-
* Builds footer groups for the
|
|
474
|
+
* Builds footer groups for the start pinned region.
|
|
467
475
|
*
|
|
468
|
-
* Footer groups reuse the
|
|
476
|
+
* Footer groups reuse the start header groups in reverse order.
|
|
469
477
|
*
|
|
470
478
|
* @example
|
|
471
479
|
* ```ts
|
|
472
|
-
* const footerGroups =
|
|
480
|
+
* const footerGroups = table_getStartFooterGroups(table)
|
|
473
481
|
* ```
|
|
474
482
|
*/
|
|
475
|
-
export function
|
|
483
|
+
export function table_getStartFooterGroups<
|
|
476
484
|
TFeatures extends TableFeatures,
|
|
477
485
|
TData extends RowData,
|
|
478
486
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
479
487
|
const headerGroups = callMemoOrStaticFn(
|
|
480
488
|
table,
|
|
481
|
-
'
|
|
482
|
-
|
|
489
|
+
'getStartHeaderGroups',
|
|
490
|
+
table_getStartHeaderGroups,
|
|
483
491
|
)
|
|
484
492
|
return [...headerGroups].reverse()
|
|
485
493
|
}
|
|
486
494
|
|
|
487
495
|
/**
|
|
488
|
-
* Builds footer groups for the
|
|
496
|
+
* Builds footer groups for the end pinned region.
|
|
489
497
|
*
|
|
490
|
-
* Footer groups reuse the
|
|
498
|
+
* Footer groups reuse the end header groups in reverse order.
|
|
491
499
|
*
|
|
492
500
|
* @example
|
|
493
501
|
* ```ts
|
|
494
|
-
* const footerGroups =
|
|
502
|
+
* const footerGroups = table_getEndFooterGroups(table)
|
|
495
503
|
* ```
|
|
496
504
|
*/
|
|
497
|
-
export function
|
|
505
|
+
export function table_getEndFooterGroups<
|
|
498
506
|
TFeatures extends TableFeatures,
|
|
499
507
|
TData extends RowData,
|
|
500
508
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
501
509
|
const headerGroups = callMemoOrStaticFn(
|
|
502
510
|
table,
|
|
503
|
-
'
|
|
504
|
-
|
|
511
|
+
'getEndHeaderGroups',
|
|
512
|
+
table_getEndHeaderGroups,
|
|
505
513
|
)
|
|
506
514
|
return [...headerGroups].reverse()
|
|
507
515
|
}
|
|
@@ -531,23 +539,23 @@ export function table_getCenterFooterGroups<
|
|
|
531
539
|
// flat headers
|
|
532
540
|
|
|
533
541
|
/**
|
|
534
|
-
* Flattens every header from the
|
|
542
|
+
* Flattens every header from the start pinned header groups.
|
|
535
543
|
*
|
|
536
544
|
* Parent headers and placeholder headers are included.
|
|
537
545
|
*
|
|
538
546
|
* @example
|
|
539
547
|
* ```ts
|
|
540
|
-
* const headers =
|
|
548
|
+
* const headers = table_getStartFlatHeaders(table)
|
|
541
549
|
* ```
|
|
542
550
|
*/
|
|
543
|
-
export function
|
|
551
|
+
export function table_getStartFlatHeaders<
|
|
544
552
|
TFeatures extends TableFeatures,
|
|
545
553
|
TData extends RowData,
|
|
546
554
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
547
555
|
const leftHeaderGroups = callMemoOrStaticFn(
|
|
548
556
|
table,
|
|
549
|
-
'
|
|
550
|
-
|
|
557
|
+
'getStartHeaderGroups',
|
|
558
|
+
table_getStartHeaderGroups,
|
|
551
559
|
)
|
|
552
560
|
const result: Array<Header<TFeatures, TData, unknown>> = []
|
|
553
561
|
for (let i = 0; i < leftHeaderGroups.length; i++) {
|
|
@@ -560,23 +568,23 @@ export function table_getLeftFlatHeaders<
|
|
|
560
568
|
}
|
|
561
569
|
|
|
562
570
|
/**
|
|
563
|
-
* Flattens every header from the
|
|
571
|
+
* Flattens every header from the end pinned header groups.
|
|
564
572
|
*
|
|
565
573
|
* Parent headers and placeholder headers are included.
|
|
566
574
|
*
|
|
567
575
|
* @example
|
|
568
576
|
* ```ts
|
|
569
|
-
* const headers =
|
|
577
|
+
* const headers = table_getEndFlatHeaders(table)
|
|
570
578
|
* ```
|
|
571
579
|
*/
|
|
572
|
-
export function
|
|
580
|
+
export function table_getEndFlatHeaders<
|
|
573
581
|
TFeatures extends TableFeatures,
|
|
574
582
|
TData extends RowData,
|
|
575
583
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
576
584
|
const rightHeaderGroups = callMemoOrStaticFn(
|
|
577
585
|
table,
|
|
578
|
-
'
|
|
579
|
-
|
|
586
|
+
'getEndHeaderGroups',
|
|
587
|
+
table_getEndHeaderGroups,
|
|
580
588
|
)
|
|
581
589
|
const result: Array<Header<TFeatures, TData, unknown>> = []
|
|
582
590
|
for (let i = 0; i < rightHeaderGroups.length; i++) {
|
|
@@ -620,44 +628,44 @@ export function table_getCenterFlatHeaders<
|
|
|
620
628
|
// leaf headers
|
|
621
629
|
|
|
622
630
|
/**
|
|
623
|
-
* Collects leaf headers for the
|
|
631
|
+
* Collects leaf headers for the start pinned region.
|
|
624
632
|
*
|
|
625
|
-
* Parent headers are filtered out from the
|
|
633
|
+
* Parent headers are filtered out from the start flat header list.
|
|
626
634
|
*
|
|
627
635
|
* @example
|
|
628
636
|
* ```ts
|
|
629
|
-
* const headers =
|
|
637
|
+
* const headers = table_getStartLeafHeaders(table)
|
|
630
638
|
* ```
|
|
631
639
|
*/
|
|
632
|
-
export function
|
|
640
|
+
export function table_getStartLeafHeaders<
|
|
633
641
|
TFeatures extends TableFeatures,
|
|
634
642
|
TData extends RowData,
|
|
635
643
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
636
644
|
return callMemoOrStaticFn(
|
|
637
645
|
table,
|
|
638
|
-
'
|
|
639
|
-
|
|
646
|
+
'getStartFlatHeaders',
|
|
647
|
+
table_getStartFlatHeaders,
|
|
640
648
|
).filter((header) => !header.subHeaders.length)
|
|
641
649
|
}
|
|
642
650
|
|
|
643
651
|
/**
|
|
644
|
-
* Collects leaf headers for the
|
|
652
|
+
* Collects leaf headers for the end pinned region.
|
|
645
653
|
*
|
|
646
|
-
* Parent headers are filtered out from the
|
|
654
|
+
* Parent headers are filtered out from the end flat header list.
|
|
647
655
|
*
|
|
648
656
|
* @example
|
|
649
657
|
* ```ts
|
|
650
|
-
* const headers =
|
|
658
|
+
* const headers = table_getEndLeafHeaders(table)
|
|
651
659
|
* ```
|
|
652
660
|
*/
|
|
653
|
-
export function
|
|
661
|
+
export function table_getEndLeafHeaders<
|
|
654
662
|
TFeatures extends TableFeatures,
|
|
655
663
|
TData extends RowData,
|
|
656
664
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
657
665
|
return callMemoOrStaticFn(
|
|
658
666
|
table,
|
|
659
|
-
'
|
|
660
|
-
|
|
667
|
+
'getEndFlatHeaders',
|
|
668
|
+
table_getEndFlatHeaders,
|
|
661
669
|
).filter((header) => !header.subHeaders.length)
|
|
662
670
|
}
|
|
663
671
|
|
|
@@ -685,61 +693,61 @@ export function table_getCenterLeafHeaders<
|
|
|
685
693
|
// leaf columns
|
|
686
694
|
|
|
687
695
|
/**
|
|
688
|
-
* Resolves leaf columns pinned to the
|
|
696
|
+
* Resolves leaf columns pinned to the start region.
|
|
689
697
|
*
|
|
690
|
-
* The result follows `state.columnPinning.
|
|
698
|
+
* The result follows `state.columnPinning.start` order and skips stale ids that
|
|
691
699
|
* no longer correspond to a leaf column.
|
|
692
700
|
*
|
|
693
701
|
* @example
|
|
694
702
|
* ```ts
|
|
695
|
-
* const columns =
|
|
703
|
+
* const columns = table_getStartLeafColumns(table)
|
|
696
704
|
* ```
|
|
697
705
|
*/
|
|
698
|
-
export function
|
|
706
|
+
export function table_getStartLeafColumns<
|
|
699
707
|
TFeatures extends TableFeatures,
|
|
700
708
|
TData extends RowData,
|
|
701
709
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
702
|
-
const {
|
|
710
|
+
const { start } =
|
|
703
711
|
table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
704
712
|
const leafColumnsById = table.getAllLeafColumnsById()
|
|
705
713
|
const result: Array<Column_Internal<TFeatures, TData, unknown>> = []
|
|
706
|
-
for (let i = 0; i <
|
|
707
|
-
const column = leafColumnsById[
|
|
714
|
+
for (let i = 0; i < start.length; i++) {
|
|
715
|
+
const column = leafColumnsById[start[i]!]
|
|
708
716
|
if (column) result.push(column)
|
|
709
717
|
}
|
|
710
718
|
return result
|
|
711
719
|
}
|
|
712
720
|
|
|
713
721
|
/**
|
|
714
|
-
* Resolves leaf columns pinned to the
|
|
722
|
+
* Resolves leaf columns pinned to the end region.
|
|
715
723
|
*
|
|
716
|
-
* The result follows `state.columnPinning.
|
|
724
|
+
* The result follows `state.columnPinning.end` order and skips stale ids that
|
|
717
725
|
* no longer correspond to a leaf column.
|
|
718
726
|
*
|
|
719
727
|
* @example
|
|
720
728
|
* ```ts
|
|
721
|
-
* const columns =
|
|
729
|
+
* const columns = table_getEndLeafColumns(table)
|
|
722
730
|
* ```
|
|
723
731
|
*/
|
|
724
|
-
export function
|
|
732
|
+
export function table_getEndLeafColumns<
|
|
725
733
|
TFeatures extends TableFeatures,
|
|
726
734
|
TData extends RowData,
|
|
727
735
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
728
|
-
const {
|
|
736
|
+
const { end } =
|
|
729
737
|
table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
730
738
|
const leafColumnsById = table.getAllLeafColumnsById()
|
|
731
739
|
const result: Array<Column_Internal<TFeatures, TData, unknown>> = []
|
|
732
|
-
for (let i = 0; i <
|
|
733
|
-
const column = leafColumnsById[
|
|
740
|
+
for (let i = 0; i < end.length; i++) {
|
|
741
|
+
const column = leafColumnsById[end[i]!]
|
|
734
742
|
if (column) result.push(column)
|
|
735
743
|
}
|
|
736
744
|
return result
|
|
737
745
|
}
|
|
738
746
|
|
|
739
747
|
/**
|
|
740
|
-
* Resolves leaf columns that are not pinned to either side.
|
|
748
|
+
* Resolves leaf columns that are not pinned to either logical side.
|
|
741
749
|
*
|
|
742
|
-
*
|
|
750
|
+
* Start- and end-pinned ids are removed from `table.getAllLeafColumns()`.
|
|
743
751
|
*
|
|
744
752
|
* @example
|
|
745
753
|
* ```ts
|
|
@@ -750,19 +758,19 @@ export function table_getCenterLeafColumns<
|
|
|
750
758
|
TFeatures extends TableFeatures,
|
|
751
759
|
TData extends RowData,
|
|
752
760
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
753
|
-
const {
|
|
761
|
+
const { start, end } =
|
|
754
762
|
table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
755
|
-
if (!
|
|
763
|
+
if (!start.length && !end.length) {
|
|
756
764
|
return table.getAllLeafColumns()
|
|
757
765
|
}
|
|
758
|
-
const
|
|
759
|
-
return table.getAllLeafColumns().filter((d) => !
|
|
766
|
+
const startAndEnd: Array<string> = [...start, ...end]
|
|
767
|
+
return table.getAllLeafColumns().filter((d) => !startAndEnd.includes(d.id))
|
|
760
768
|
}
|
|
761
769
|
|
|
762
770
|
/**
|
|
763
771
|
* Resolves leaf columns for a requested pinning region.
|
|
764
772
|
*
|
|
765
|
-
* Pass `'
|
|
773
|
+
* Pass `'start'`, `'center'`, or `'end'` for a partition, or pass `false` to
|
|
766
774
|
* read all leaf columns without partitioning.
|
|
767
775
|
*
|
|
768
776
|
* @example
|
|
@@ -779,17 +787,17 @@ export function table_getPinnedLeafColumns<
|
|
|
779
787
|
) {
|
|
780
788
|
return !position
|
|
781
789
|
? table.getAllLeafColumns()
|
|
782
|
-
: position === '
|
|
790
|
+
: position === 'start'
|
|
783
791
|
? callMemoOrStaticFn(
|
|
784
792
|
table,
|
|
785
|
-
'
|
|
786
|
-
|
|
793
|
+
'getStartLeafColumns',
|
|
794
|
+
table_getStartLeafColumns,
|
|
787
795
|
)
|
|
788
|
-
: position === '
|
|
796
|
+
: position === 'end'
|
|
789
797
|
? callMemoOrStaticFn(
|
|
790
798
|
table,
|
|
791
|
-
'
|
|
792
|
-
|
|
799
|
+
'getEndLeafColumns',
|
|
800
|
+
table_getEndLeafColumns,
|
|
793
801
|
)
|
|
794
802
|
: callMemoOrStaticFn(
|
|
795
803
|
table,
|
|
@@ -801,46 +809,46 @@ export function table_getPinnedLeafColumns<
|
|
|
801
809
|
// visible leaf columns
|
|
802
810
|
|
|
803
811
|
/**
|
|
804
|
-
* Resolves visible leaf columns pinned to the
|
|
812
|
+
* Resolves visible leaf columns pinned to the start region.
|
|
805
813
|
*
|
|
806
|
-
* Hidden pinned columns are filtered out after the
|
|
814
|
+
* Hidden pinned columns are filtered out after the start pin order is applied.
|
|
807
815
|
*
|
|
808
816
|
* @example
|
|
809
817
|
* ```ts
|
|
810
|
-
* const columns =
|
|
818
|
+
* const columns = table_getStartVisibleLeafColumns(table)
|
|
811
819
|
* ```
|
|
812
820
|
*/
|
|
813
|
-
export function
|
|
821
|
+
export function table_getStartVisibleLeafColumns<
|
|
814
822
|
TFeatures extends TableFeatures,
|
|
815
823
|
TData extends RowData,
|
|
816
824
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
817
825
|
return callMemoOrStaticFn(
|
|
818
826
|
table,
|
|
819
|
-
'
|
|
820
|
-
|
|
827
|
+
'getStartLeafColumns',
|
|
828
|
+
table_getStartLeafColumns,
|
|
821
829
|
).filter((column) =>
|
|
822
830
|
callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),
|
|
823
831
|
)
|
|
824
832
|
}
|
|
825
833
|
|
|
826
834
|
/**
|
|
827
|
-
* Resolves visible leaf columns pinned to the
|
|
835
|
+
* Resolves visible leaf columns pinned to the end region.
|
|
828
836
|
*
|
|
829
|
-
* Hidden pinned columns are filtered out after the
|
|
837
|
+
* Hidden pinned columns are filtered out after the end pin order is applied.
|
|
830
838
|
*
|
|
831
839
|
* @example
|
|
832
840
|
* ```ts
|
|
833
|
-
* const columns =
|
|
841
|
+
* const columns = table_getEndVisibleLeafColumns(table)
|
|
834
842
|
* ```
|
|
835
843
|
*/
|
|
836
|
-
export function
|
|
844
|
+
export function table_getEndVisibleLeafColumns<
|
|
837
845
|
TFeatures extends TableFeatures,
|
|
838
846
|
TData extends RowData,
|
|
839
847
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
840
848
|
return callMemoOrStaticFn(
|
|
841
849
|
table,
|
|
842
|
-
'
|
|
843
|
-
|
|
850
|
+
'getEndLeafColumns',
|
|
851
|
+
table_getEndLeafColumns,
|
|
844
852
|
).filter((column) =>
|
|
845
853
|
callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),
|
|
846
854
|
)
|
|
@@ -873,12 +881,12 @@ export function table_getCenterVisibleLeafColumns<
|
|
|
873
881
|
/**
|
|
874
882
|
* Resolves visible leaf columns for a requested pinning region.
|
|
875
883
|
*
|
|
876
|
-
* Omit `position` to get all visible leaf columns, or pass `'
|
|
877
|
-
* or `'
|
|
884
|
+
* Omit `position` to get all visible leaf columns, or pass `'start'`, `'center'`,
|
|
885
|
+
* or `'end'` to get one partition.
|
|
878
886
|
*
|
|
879
887
|
* @example
|
|
880
888
|
* ```ts
|
|
881
|
-
* const columns = table_getPinnedVisibleLeafColumns(table, '
|
|
889
|
+
* const columns = table_getPinnedVisibleLeafColumns(table, 'start')
|
|
882
890
|
* ```
|
|
883
891
|
*/
|
|
884
892
|
export function table_getPinnedVisibleLeafColumns<
|
|
@@ -894,17 +902,17 @@ export function table_getPinnedVisibleLeafColumns<
|
|
|
894
902
|
'getVisibleLeafColumns',
|
|
895
903
|
table_getVisibleLeafColumns,
|
|
896
904
|
)
|
|
897
|
-
: position === '
|
|
905
|
+
: position === 'start'
|
|
898
906
|
? callMemoOrStaticFn(
|
|
899
907
|
table,
|
|
900
|
-
'
|
|
901
|
-
|
|
908
|
+
'getStartVisibleLeafColumns',
|
|
909
|
+
table_getStartVisibleLeafColumns,
|
|
902
910
|
)
|
|
903
|
-
: position === '
|
|
911
|
+
: position === 'end'
|
|
904
912
|
? callMemoOrStaticFn(
|
|
905
913
|
table,
|
|
906
|
-
'
|
|
907
|
-
|
|
914
|
+
'getEndVisibleLeafColumns',
|
|
915
|
+
table_getEndVisibleLeafColumns,
|
|
908
916
|
)
|
|
909
917
|
: callMemoOrStaticFn(
|
|
910
918
|
table,
|