@@ -360,50 +360,54 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
360360 return selectedRowIds . has ( rowId ) ;
361361 } ) && ! allPageRowsSelected ;
362362
363+ const showToolbar = searchable || exportable || ( selectable && selectedRowIds . size > 0 ) ;
364+
363365 return (
364- < div className = { `space-y -4 ${ className || '' } ` } >
366+ < div className = { `flex flex-col h-full gap -4 ${ className || '' } ` } >
365367 { /* Toolbar */ }
366- < div className = "flex items-center justify-between gap-4" >
367- < div className = "flex items-center gap-2 flex-1" >
368- { searchable && (
369- < div className = "relative max-w-sm flex-1" >
370- < Search className = "absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
371- < Input
372- placeholder = "Search..."
373- value = { searchQuery }
374- onChange = { ( e ) => {
375- setSearchQuery ( e . target . value ) ;
376- setCurrentPage ( 1 ) ;
377- } }
378- className = "pl-8"
379- />
380- </ div >
381- ) }
382- </ div >
383-
384- < div className = "flex items-center gap-2" >
385- { exportable && (
386- < Button
387- variant = "outline"
388- size = "sm"
389- onClick = { handleExport }
390- disabled = { sortedData . length === 0 }
391- >
392- < Download className = "h-4 w-4 mr-2" />
393- Export CSV
394- </ Button >
395- ) }
368+ { showToolbar && (
369+ < div className = "flex items-center justify-between gap-4 flex-none" >
370+ < div className = "flex items-center gap-2 flex-1" >
371+ { searchable && (
372+ < div className = "relative max-w-sm flex-1" >
373+ < Search className = "absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
374+ < Input
375+ placeholder = "Search..."
376+ value = { searchQuery }
377+ onChange = { ( e ) => {
378+ setSearchQuery ( e . target . value ) ;
379+ setCurrentPage ( 1 ) ;
380+ } }
381+ className = "pl-8"
382+ />
383+ </ div >
384+ ) }
385+ </ div >
396386
397- { selectable && selectedRowIds . size > 0 && (
398- < div className = "text-sm text-muted-foreground" >
399- { selectedRowIds . size } selected
400- </ div >
401- ) }
387+ < div className = "flex items-center gap-2" >
388+ { exportable && (
389+ < Button
390+ variant = "outline"
391+ size = "sm"
392+ onClick = { handleExport }
393+ disabled = { sortedData . length === 0 }
394+ >
395+ < Download className = "h-4 w-4 mr-2" />
396+ Export CSV
397+ </ Button >
398+ ) }
399+
400+ { selectable && selectedRowIds . size > 0 && (
401+ < div className = "text-sm text-muted-foreground" >
402+ { selectedRowIds . size } selected
403+ </ div >
404+ ) }
405+ </ div >
402406 </ div >
403- </ div >
407+ ) }
404408
405409 { /* Table */ }
406- < div className = "rounded-md border max-h-[600px] overflow-auto relative" >
410+ < div className = "rounded-md border flex-1 min-h-0 overflow-auto relative bg-background " >
407411 < Table >
408412 { caption && < TableCaption > { caption } </ TableCaption > }
409413 < TableHeader className = "sticky top-0 bg-background z-10 shadow-sm" >
0 commit comments