1- import React from " react" ;
2- import data from " @/data/persistence/coverage.json" ;
1+ import React from ' react' ;
2+ import data from ' @/data/persistence/coverage.json' ;
33import {
44 Table ,
55 TableHeader ,
66 TableBody ,
77 TableRow ,
88 TableHead ,
99 TableCell ,
10- } from " @/components/ui/table" ;
10+ } from ' @/components/ui/table' ;
1111import {
1212 useReactTable ,
1313 getCoreRowModel ,
1414 getSortedRowModel ,
1515 flexRender ,
1616 getFilteredRowModel ,
1717 getPaginationRowModel ,
18- } from "@tanstack/react-table" ;
19- import type { SortingState , ColumnDef , ColumnFiltersState } from "@tanstack/react-table" ;
18+ } from '@tanstack/react-table' ;
19+ import type {
20+ SortingState ,
21+ ColumnDef ,
22+ ColumnFiltersState ,
23+ } from '@tanstack/react-table' ;
2024
2125const coverage = Object . values ( data ) ;
2226
2327const columns : ColumnDef < any > [ ] = [
2428 {
25- accessorKey : " full_name" ,
26- header : ( ) => " Service" ,
29+ accessorKey : ' full_name' ,
30+ header : ( ) => ' Service' ,
2731 cell : ( { row } ) => (
2832 < a href = { `/aws/${ row . original . service } ` } > { row . original . full_name } </ a >
2933 ) ,
3034 enableColumnFilter : true ,
3135 filterFn : ( row , columnId , filterValue ) => {
3236 return row . original . full_name
3337 . toLowerCase ( )
34- . includes ( ( filterValue ?? "" ) . toLowerCase ( ) ) ;
38+ . includes ( ( filterValue ?? '' ) . toLowerCase ( ) ) ;
3539 } ,
36- meta : { className : "w-1/3" } ,
40+ meta : { className : 'w-[30%]' } ,
3741 } ,
3842 {
39- accessorKey : " support" ,
40- header : ( ) => " Supported" ,
43+ accessorKey : ' support' ,
44+ header : ( ) => ' Supported' ,
4145 cell : ( { row } ) =>
42- row . original . support === " supported" ||
43- row . original . support === " supported with limitations"
44- ? "✔️"
45- : "" ,
46- meta : { className : "w-1/6" } ,
46+ row . original . support === ' supported' ||
47+ row . original . support === ' supported with limitations'
48+ ? '✔️'
49+ : '' ,
50+ meta : { className : 'w-[15%] text-center' } ,
4751 enableSorting : true ,
4852 sortingFn : ( rowA , rowB ) => {
4953 // Sort supported to the top
5054 const a = rowA . original . support ;
5155 const b = rowB . original . support ;
5256 if ( a === b ) return 0 ;
53- if ( a === " supported" ) return - 1 ;
54- if ( b === " supported" ) return 1 ;
55- if ( a === " supported with limitations" ) return - 1 ;
56- if ( b === " supported with limitations" ) return 1 ;
57+ if ( a === ' supported' ) return - 1 ;
58+ if ( b === ' supported' ) return 1 ;
59+ if ( a === ' supported with limitations' ) return - 1 ;
60+ if ( b === ' supported with limitations' ) return 1 ;
5761 return a . localeCompare ( b ) ;
5862 } ,
5963 } ,
6064 {
61- accessorKey : " test_suite" ,
62- header : ( ) => " Persistence Test Suite" ,
63- cell : ( { row } ) => ( row . original . test_suite ? "✔️" : "" ) ,
64- meta : { className : "w-1/6" } ,
65+ accessorKey : ' test_suite' ,
66+ header : ( ) => ' Persistence Test Suite' ,
67+ cell : ( { row } ) => ( row . original . test_suite ? '✔️' : '' ) ,
68+ meta : { className : 'w-[20%] text-center' } ,
6569 enableSorting : true ,
6670 } ,
6771 {
68- accessorKey : " limitations" ,
69- header : ( ) => " Limitations" ,
72+ accessorKey : ' limitations' ,
73+ header : ( ) => ' Limitations' ,
7074 cell : ( { row } ) => row . original . limitations ,
7175 enableSorting : false ,
72- meta : { className : " whitespace-normal" } ,
76+ meta : { className : 'w-[35%] whitespace-normal' } ,
7377 } ,
7478] ;
7579
7680export default function PersistenceCoverage ( ) {
7781 const [ sorting , setSorting ] = React . useState < SortingState > ( [
78- { id : " full_name" , desc : false } ,
82+ { id : ' full_name' , desc : false } ,
7983 ] ) ;
80- const [ columnFilters , setColumnFilters ] = React . useState < ColumnFiltersState > ( [ ] ) ;
84+ const [ columnFilters , setColumnFilters ] = React . useState < ColumnFiltersState > (
85+ [ ]
86+ ) ;
8187
8288 const table = useReactTable ( {
8389 data : coverage ,
@@ -100,39 +106,53 @@ export default function PersistenceCoverage() {
100106 type = "text"
101107 placeholder = "Filter by service name..."
102108 value = {
103- table . getColumn ( " full_name" ) ?. getFilterValue ( ) as string || ""
109+ ( table . getColumn ( ' full_name' ) ?. getFilterValue ( ) as string ) || ''
104110 }
105- onChange = { e =>
106- table . getColumn ( " full_name" ) ?. setFilterValue ( e . target . value )
111+ onChange = { ( e ) =>
112+ table . getColumn ( ' full_name' ) ?. setFilterValue ( e . target . value )
107113 }
108114 className = "border rounded px-2 py-1 w-full max-w-xs"
109115 />
110116 </ div >
111- < div className = "rounded-md border" >
112- < Table >
117+ < div className = "rounded-md border w-full " >
118+ < Table className = "w-full table-fixed" >
113119 < TableHeader >
114120 { table . getHeaderGroups ( ) . map ( ( headerGroup ) => (
115121 < TableRow key = { headerGroup . id } >
116122 { headerGroup . headers . map ( ( header ) => {
117123 const canSort = header . column . getCanSort ( ) ;
118- const meta = header . column . columnDef . meta as { className ?: string } | undefined ;
124+ const meta = header . column . columnDef . meta as
125+ | { className ?: string }
126+ | undefined ;
119127 return (
120128 < TableHead
121129 key = { header . id }
122- onClick = { canSort ? header . column . getToggleSortingHandler ( ) : undefined }
130+ onClick = {
131+ canSort
132+ ? header . column . getToggleSortingHandler ( )
133+ : undefined
134+ }
123135 className = {
124- ( meta ?. className || "" ) +
125- ( canSort ? " cursor-pointer select-none" : "" )
136+ ( meta ?. className || '' ) +
137+ ( canSort ? ' cursor-pointer select-none' : '' )
126138 }
139+ style = { {
140+ width : meta ?. className ?. includes ( 'w-[' )
141+ ? meta . className . match ( / w - \[ ( \d + ) % \] / ) ?. [ 1 ] + '%'
142+ : 'auto' ,
143+ } }
127144 >
128- { flexRender ( header . column . columnDef . header , header . getContext ( ) ) }
145+ { flexRender (
146+ header . column . columnDef . header ,
147+ header . getContext ( )
148+ ) }
129149 { canSort && (
130150 < span >
131- { header . column . getIsSorted ( ) === " asc"
132- ? " ▲"
133- : header . column . getIsSorted ( ) === " desc"
134- ? " ▼"
135- : "" }
151+ { header . column . getIsSorted ( ) === ' asc'
152+ ? ' ▲'
153+ : header . column . getIsSorted ( ) === ' desc'
154+ ? ' ▼'
155+ : '' }
136156 </ span >
137157 ) }
138158 </ TableHead >
@@ -145,13 +165,23 @@ export default function PersistenceCoverage() {
145165 { table . getRowModel ( ) . rows . map ( ( row ) => (
146166 < TableRow key = { row . id } >
147167 { row . getVisibleCells ( ) . map ( ( cell ) => {
148- const meta = cell . column . columnDef . meta as { className ?: string } | undefined ;
168+ const meta = cell . column . columnDef . meta as
169+ | { className ?: string }
170+ | undefined ;
149171 return (
150172 < TableCell
151173 key = { cell . id }
152174 className = { meta ?. className || undefined }
175+ style = { {
176+ width : meta ?. className ?. includes ( 'w-[' )
177+ ? meta . className . match ( / w - \[ ( \d + ) % \] / ) ?. [ 1 ] + '%'
178+ : 'auto' ,
179+ } }
153180 >
154- { flexRender ( cell . column . columnDef . cell , cell . getContext ( ) ) }
181+ { flexRender (
182+ cell . column . columnDef . cell ,
183+ cell . getContext ( )
184+ ) }
155185 </ TableCell >
156186 ) ;
157187 } ) }
@@ -169,7 +199,8 @@ export default function PersistenceCoverage() {
169199 Previous
170200 </ button >
171201 < span >
172- Page { table . getState ( ) . pagination . pageIndex + 1 } of { table . getPageCount ( ) }
202+ Page { table . getState ( ) . pagination . pageIndex + 1 } of{ ' ' }
203+ { table . getPageCount ( ) }
173204 </ span >
174205 < button
175206 className = "px-3 py-1 border rounded disabled:opacity-50"
@@ -181,4 +212,4 @@ export default function PersistenceCoverage() {
181212 </ div >
182213 </ div >
183214 ) ;
184- }
215+ }
0 commit comments