@@ -31,13 +31,15 @@ import {
31
31
} from ".." ;
32
32
import {
33
33
cellContainerRecipe ,
34
+ columnFooter ,
34
35
columnHeader ,
35
36
lastLeftStickyColumn ,
36
37
rowContainer ,
37
38
sectionHeader ,
38
39
sectionHeaderContainer ,
39
40
selectedRowBackgroundColor ,
40
41
sortIconContainer ,
42
+ stickyColumnFooter ,
41
43
stickyColumnHeader ,
42
44
stickyTopHeight ,
43
45
table ,
@@ -104,6 +106,7 @@ type Props<
104
106
noResultsFeedbackSize ?: FeedbackProps [ "size" ] ;
105
107
initialSorting ?: Array < SortingRule < C > > ;
106
108
stickyHeaders ?: boolean ;
109
+ stickyFooters ?: boolean ;
107
110
height ?: { custom : string | number } ;
108
111
onRowPress ?: ( row : Row < RowType < C > > ) => void ;
109
112
virtualizeRows ?: boolean | { estimateRowHeight : ( index : number ) => number } ;
@@ -143,6 +146,7 @@ export function Table<
143
146
onSort,
144
147
initialSorting,
145
148
stickyHeaders,
149
+ stickyFooters = true ,
146
150
height,
147
151
onRowPress,
148
152
virtualizeRows : virtualizeRowsConfig ,
@@ -417,6 +421,8 @@ export function Table<
417
421
}
418
422
} ) ;
419
423
424
+ const hasFooters = headerGroups . at ( - 1 ) ?. headers . some ( ( h ) => h . Footer ) ;
425
+
420
426
return (
421
427
< Box
422
428
{ ...getTableProps ( ) }
@@ -459,6 +465,25 @@ export function Table<
459
465
{ paddingTopRow }
460
466
{ renderedRows }
461
467
{ paddingBottomRow }
468
+ { hasFooters &&
469
+ headerGroups . at ( - 1 ) ?. headers . map ( ( header , index ) => (
470
+ < ColumnFooter
471
+ column = { header }
472
+ key = { header . id }
473
+ style = { {
474
+ ...stickyLeftColumnStyle [ header . id ] ,
475
+ } }
476
+ lastLeftSticky = {
477
+ header . columns
478
+ ? header . id === stickyLeftColumnGroupsIds . at ( - 1 )
479
+ : index === lastStickyColumnIndex
480
+ }
481
+ stickyFooters = { stickyFooters }
482
+ sticky = { stickyLeftColumnsIds . includes ( header . id ) }
483
+ first = { index === 0 }
484
+ last = { index + 1 === flatColumns . length }
485
+ />
486
+ ) ) }
462
487
</ Box >
463
488
) ;
464
489
}
@@ -593,6 +618,58 @@ function ColumnHeader<D extends Record<string, unknown>>({
593
618
) ;
594
619
}
595
620
621
+ function ColumnFooter < D extends Record < string , unknown > > ( {
622
+ column,
623
+ style,
624
+ lastLeftSticky,
625
+ stickyFooters,
626
+ sticky,
627
+ first,
628
+ last,
629
+ } : {
630
+ column : ColumnInstance < D > | HeaderGroup < D > ;
631
+ style : CSSProperties ;
632
+ lastLeftSticky : boolean ;
633
+ stickyFooters : boolean ;
634
+ sticky : boolean ;
635
+ first : boolean ;
636
+ last : boolean ;
637
+ } ) {
638
+ const config = useBentoConfig ( ) . table ;
639
+
640
+ return (
641
+ < Box
642
+ className = { [ lastLeftSticky && lastLeftStickyColumn , stickyFooters && stickyColumnFooter ] }
643
+ style = { {
644
+ ...style ,
645
+ zIndex : sticky ? zIndexes . leftStickyHeader : zIndexes . header ,
646
+ } }
647
+ >
648
+ < Box
649
+ className = { columnFooter }
650
+ background = { config . footerBackgroundColor }
651
+ color = { config . footerForegroundColor }
652
+ { ...column . getFooterProps ( ) }
653
+ textAlign = { column . align }
654
+ { ...config . padding . footer }
655
+ >
656
+ { column . Footer && (
657
+ < Box
658
+ paddingLeft = { first ? config . boundaryPadding : undefined }
659
+ paddingRight = { last ? config . boundaryPadding : undefined }
660
+ >
661
+ < Columns space = { 8 } alignY = "center" align = { column . align } >
662
+ < Column width = "content" >
663
+ < Label size = "large" > { column . render ( "Footer" ) as any } </ Label >
664
+ </ Column >
665
+ </ Columns >
666
+ </ Box >
667
+ ) }
668
+ </ Box >
669
+ </ Box >
670
+ ) ;
671
+ }
672
+
596
673
function SectionHeader ( {
597
674
label,
598
675
numberOfStickyColumns,
0 commit comments