@tanstack/table-core 8.19.1 → 8.19.2
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/lib/features/RowPinning.d.ts +1 -1
- package/build/lib/features/RowPinning.js +7 -7
- package/build/lib/features/RowPinning.js.map +1 -1
- package/build/lib/index.esm.js +7 -7
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +7 -7
- package/build/lib/index.mjs.map +1 -1
- package/build/umd/index.development.js +7 -7
- 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/features/RowPinning.ts +35 -31
package/package.json
CHANGED
|
@@ -76,7 +76,11 @@ export interface RowPinningRow {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export interface RowPinningInstance<TData extends RowData> {
|
|
79
|
-
_getPinnedRows: (
|
|
79
|
+
_getPinnedRows: (
|
|
80
|
+
visiblePinnedRows: Array<Row<TData>>,
|
|
81
|
+
pinnedRowIds: Array<string> | undefined,
|
|
82
|
+
position: 'top' | 'bottom'
|
|
83
|
+
) => Row<TData>[]
|
|
80
84
|
/**
|
|
81
85
|
* Returns all bottom pinned rows.
|
|
82
86
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getbottomrows)
|
|
@@ -199,9 +203,9 @@ export const RowPinning: TableFeature = {
|
|
|
199
203
|
const position = row.getIsPinned()
|
|
200
204
|
if (!position) return -1
|
|
201
205
|
|
|
202
|
-
const visiblePinnedRowIds =
|
|
203
|
-
.
|
|
204
|
-
|
|
206
|
+
const visiblePinnedRowIds = (
|
|
207
|
+
position === 'top' ? table.getTopRows() : table.getBottomRows()
|
|
208
|
+
)?.map(({ id }) => id)
|
|
205
209
|
|
|
206
210
|
return visiblePinnedRowIds?.indexOf(row.id) ?? -1
|
|
207
211
|
}
|
|
@@ -226,36 +230,36 @@ export const RowPinning: TableFeature = {
|
|
|
226
230
|
return Boolean(pinningState[position]?.length)
|
|
227
231
|
}
|
|
228
232
|
|
|
229
|
-
table._getPinnedRows =
|
|
230
|
-
|
|
231
|
-
table.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return row.getIsAllParentsExpanded() ? row : null
|
|
243
|
-
})
|
|
244
|
-
: //else get only visible rows that are pinned
|
|
245
|
-
(pinnedRowIds ?? []).map(
|
|
246
|
-
rowId => visibleRows.find(row => row.id === rowId)!
|
|
247
|
-
)
|
|
233
|
+
table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
|
|
234
|
+
const rows =
|
|
235
|
+
table.options.keepPinnedRows ?? true
|
|
236
|
+
? //get all rows that are pinned even if they would not be otherwise visible
|
|
237
|
+
//account for expanded parent rows, but not pagination or filtering
|
|
238
|
+
(pinnedRowIds ?? []).map(rowId => {
|
|
239
|
+
const row = table.getRow(rowId, true)
|
|
240
|
+
return row.getIsAllParentsExpanded() ? row : null
|
|
241
|
+
})
|
|
242
|
+
: //else get only visible rows that are pinned
|
|
243
|
+
(pinnedRowIds ?? []).map(
|
|
244
|
+
rowId => visibleRows.find(row => row.id === rowId)!
|
|
245
|
+
)
|
|
248
246
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
.map(d => ({ ...d, position })) as Row<TData>[]
|
|
252
|
-
},
|
|
253
|
-
getMemoOptions(table.options, 'debugRows', '_getPinnedRows')
|
|
254
|
-
)
|
|
247
|
+
return rows.filter(Boolean).map(d => ({ ...d, position })) as Row<TData>[]
|
|
248
|
+
}
|
|
255
249
|
|
|
256
|
-
table.getTopRows = (
|
|
250
|
+
table.getTopRows = memo(
|
|
251
|
+
() => [table.getRowModel().rows, table.getState().rowPinning.top],
|
|
252
|
+
(allRows, topPinnedRowIds) =>
|
|
253
|
+
table._getPinnedRows(allRows, topPinnedRowIds, 'top'),
|
|
254
|
+
getMemoOptions(table.options, 'debugRows', 'getTopRows')
|
|
255
|
+
)
|
|
257
256
|
|
|
258
|
-
table.getBottomRows = (
|
|
257
|
+
table.getBottomRows = memo(
|
|
258
|
+
() => [table.getRowModel().rows, table.getState().rowPinning.bottom],
|
|
259
|
+
(allRows, bottomPinnedRowIds) =>
|
|
260
|
+
table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'),
|
|
261
|
+
getMemoOptions(table.options, 'debugRows', 'getBottomRows')
|
|
262
|
+
)
|
|
259
263
|
|
|
260
264
|
table.getCenterRows = memo(
|
|
261
265
|
() => [
|