-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce228cb
commit b92a4fc
Showing
4 changed files
with
47 additions
and
54 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
frontend/src/components/Table/PaddingForVirtualizeTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { notUndefined, Virtualizer, type VirtualItem } from '@tanstack/react-virtual' | ||
|
||
export function PaddingForVirtualizeTable({ | ||
columLength, | ||
height, | ||
name | ||
}: { | ||
columLength: number | ||
height: number | ||
name: string | ||
}) { | ||
return ( | ||
<tr> | ||
<td aria-label={`padding ${name}`} colSpan={columLength} style={{ height }} /> | ||
</tr> | ||
) | ||
} | ||
|
||
export const getPaddingValuesForVirtualizeTable = ( | ||
virtualRows: VirtualItem[], | ||
rowVirtualizer: Virtualizer<HTMLDivElement, Element> | ||
): [number, number] => | ||
virtualRows?.length > 0 | ||
? [ | ||
notUndefined(virtualRows[0]).start - rowVirtualizer.options.scrollMargin, | ||
rowVirtualizer.getTotalSize() - notUndefined(virtualRows[virtualRows.length - 1]).end | ||
] | ||
: [0, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters