@@ -15,21 +15,22 @@ import {
15
15
import { rankItem } from '@tanstack/match-sorter-utils'
16
16
import {
17
17
ColumnDef ,
18
- FilterFn ,
19
- GroupingState ,
20
- SortingState ,
21
18
createSolidTable ,
19
+ FilterFn ,
22
20
flexRender ,
23
21
getCoreRowModel ,
24
22
getExpandedRowModel ,
25
23
getFilteredRowModel ,
26
24
getGroupedRowModel ,
27
25
getSortedRowModel ,
26
+ GroupingState ,
27
+ SortingState ,
28
28
} from '@tanstack/solid-table'
29
29
import byteSize from 'byte-size'
30
30
import dayjs from 'dayjs'
31
31
import { uniq } from 'lodash'
32
32
import { twMerge } from 'tailwind-merge'
33
+ import { Virtualizer } from 'virtua/solid'
33
34
import { closeAllConnectionsAPI , closeSingleConnectionAPI } from '~/apis'
34
35
import {
35
36
Button ,
@@ -367,6 +368,8 @@ export default () => {
367
368
} ,
368
369
] )
369
370
371
+ let scrollRef : HTMLDivElement | undefined
372
+
370
373
return (
371
374
< >
372
375
< DocumentTitle > { t ( 'connections' ) } </ DocumentTitle >
@@ -476,20 +479,23 @@ export default () => {
476
479
</ div >
477
480
</ div >
478
481
479
- < div class = "overflow-x-auto rounded-md bg-base-300 whitespace-nowrap" >
482
+ < div
483
+ class = "h-full overflow-x-auto rounded-md bg-base-300"
484
+ ref = { scrollRef }
485
+ >
480
486
< table
481
487
class = { twMerge (
482
488
tableSizeClassName ( connectionsTableSize ( ) ) ,
483
- 'table relative rounded-none table-zebra' ,
489
+ 'table-pin-rows table h-full table-zebra' ,
484
490
) }
485
491
>
486
- < thead class = "sticky top-0 z-10 h-8" >
492
+ < thead >
487
493
< For each = { table . getHeaderGroups ( ) } >
488
494
{ ( headerGroup ) => (
489
- < tr >
495
+ < tr class = "flex" >
490
496
< For each = { headerGroup . headers } >
491
497
{ ( header ) => (
492
- < th class = "bg-base-200" >
498
+ < th class = "bg-base-200" style = { { width : '150px' } } >
493
499
< div class = { twMerge ( 'flex items-center gap-2' ) } >
494
500
{ header . column . getCanGroup ( ) ? (
495
501
< button
@@ -531,70 +537,74 @@ export default () => {
531
537
</ For >
532
538
</ thead >
533
539
534
- < tbody >
535
- < For each = { table . getRowModel ( ) . rows } >
536
- { ( row ) => (
537
- < tr class = "hover:!bg-primary hover:text-primary-content" >
538
- < For each = { row . getVisibleCells ( ) } >
539
- { ( cell ) => {
540
- return (
541
- < td
542
- class = "py-2"
543
- onContextMenu = { ( e ) => {
544
- e . preventDefault ( )
545
-
546
- const value = cell . renderValue ( ) as null | string
547
-
548
- if ( value ) writeClipboard ( value ) . catch ( ( ) => { } )
549
- } }
540
+ < Virtualizer
541
+ scrollRef = { scrollRef }
542
+ data = { table . getRowModel ( ) . rows }
543
+ as = "tbody"
544
+ item = "tr"
545
+ >
546
+ { ( row ) => (
547
+ < For each = { row . getVisibleCells ( ) } >
548
+ { ( cell ) => {
549
+ return (
550
+ < td
551
+ class = "inline-block py-2 break-words"
552
+ style = { {
553
+ width : '150px' ,
554
+ } }
555
+ onContextMenu = { ( e ) => {
556
+ e . preventDefault ( )
557
+
558
+ const value = cell . renderValue ( ) as null | string
559
+
560
+ if ( value ) writeClipboard ( value ) . catch ( ( ) => { } )
561
+ } }
562
+ >
563
+ { cell . getIsGrouped ( ) ? (
564
+ < button
565
+ class = { twMerge (
566
+ row . getCanExpand ( )
567
+ ? 'cursor-pointer'
568
+ : 'cursor-normal' ,
569
+ 'flex items-center gap-2' ,
570
+ ) }
571
+ onClick = { row . getToggleExpandedHandler ( ) }
550
572
>
551
- { cell . getIsGrouped ( ) ? (
552
- < button
553
- class = { twMerge (
554
- row . getCanExpand ( )
555
- ? 'cursor-pointer'
556
- : 'cursor-normal' ,
557
- 'flex items-center gap-2' ,
558
- ) }
559
- onClick = { row . getToggleExpandedHandler ( ) }
560
- >
561
- < div >
562
- { row . getIsExpanded ( ) ? (
563
- < IconZoomOutFilled size = { 18 } />
564
- ) : (
565
- < IconZoomInFilled size = { 18 } />
566
- ) }
567
- </ div >
568
-
569
- < div >
570
- { flexRender (
571
- cell . column . columnDef . cell ,
572
- cell . getContext ( ) ,
573
- ) }
574
- </ div >
575
-
576
- < div > ({ row . subRows . length } )</ div >
577
- </ button >
578
- ) : cell . getIsAggregated ( ) ? (
579
- flexRender (
580
- cell . column . columnDef . aggregatedCell ??
581
- cell . column . columnDef . cell ,
582
- cell . getContext ( ) ,
583
- )
584
- ) : cell . getIsPlaceholder ( ) ? null : (
585
- flexRender (
573
+ < div >
574
+ { row . getIsExpanded ( ) ? (
575
+ < IconZoomOutFilled size = { 18 } />
576
+ ) : (
577
+ < IconZoomInFilled size = { 18 } />
578
+ ) }
579
+ </ div >
580
+
581
+ < div >
582
+ { flexRender (
586
583
cell . column . columnDef . cell ,
587
584
cell . getContext ( ) ,
588
- )
589
- ) }
590
- </ td >
591
- )
592
- } }
593
- </ For >
594
- </ tr >
595
- ) }
596
- </ For >
597
- </ tbody >
585
+ ) }
586
+ </ div >
587
+
588
+ < div > ({ row . subRows . length } )</ div >
589
+ </ button >
590
+ ) : cell . getIsAggregated ( ) ? (
591
+ flexRender (
592
+ cell . column . columnDef . aggregatedCell ??
593
+ cell . column . columnDef . cell ,
594
+ cell . getContext ( ) ,
595
+ )
596
+ ) : cell . getIsPlaceholder ( ) ? null : (
597
+ flexRender (
598
+ cell . column . columnDef . cell ,
599
+ cell . getContext ( ) ,
600
+ )
601
+ ) }
602
+ </ td >
603
+ )
604
+ } }
605
+ </ For >
606
+ ) }
607
+ </ Virtualizer >
598
608
</ table >
599
609
</ div >
600
610
0 commit comments