()
| 45 | ] |
| 46 | |
| 47 | const renderTable = () => { |
| 48 | // Create table elements |
| 49 | const tableElement = document.createElement('table') |
| 50 | const theadElement = document.createElement('thead') |
| 51 | const tbodyElement = document.createElement('tbody') |
| 52 | |
| 53 | tableElement.classList.add('mb-2') |
| 54 | |
| 55 | tableElement.appendChild(theadElement) |
| 56 | tableElement.appendChild(tbodyElement) |
| 57 | |
| 58 | // Render table headers |
| 59 | table.getHeaderGroups().forEach(headerGroup => { |
| 60 | const trElement = document.createElement('tr') |
| 61 | headerGroup.headers.forEach(header => { |
| 62 | const thElement = document.createElement('th') |
| 63 | thElement.colSpan = header.colSpan |
| 64 | const divElement = document.createElement('div') |
| 65 | divElement.classList.add( |
| 66 | 'w-36', |
| 67 | ...(header.column.getCanSort() ? ['cursor-pointer', 'select-none'] : []) |
| 68 | ) |
| 69 | ;(divElement.onclick = e => header.column.getToggleSortingHandler()?.(e)), |
| 70 | (divElement.innerHTML = header.isPlaceholder |
| 71 | ? '' |
| 72 | : flexRender(header.column.columnDef.header, header.getContext())) |
| 73 | divElement.innerHTML += |
| 74 | { |
| 75 | asc: ' 🔼', |
| 76 | desc: ' 🔽', |
| 77 | }[header.column.getIsSorted() as string] ?? '' |
| 78 | thElement.appendChild(divElement) |
| 79 | trElement.appendChild(thElement) |
| 80 | }) |
| 81 | theadElement.appendChild(trElement) |
| 82 | }) |
| 83 | |
| 84 | // Render table rows |
| 85 | table.getRowModel().rows.forEach(row => { |
| 86 | const trElement = document.createElement('tr') |
| 87 | row.getVisibleCells().forEach(cell => { |
| 88 | const tdElement = document.createElement('td') |
| 89 | tdElement.innerHTML = flexRender( |
| 90 | cell.column.columnDef.cell, |
| 91 | cell.getContext() |
| 92 | ) |
| 93 | trElement.appendChild(tdElement) |
| 94 | }) |
| 95 | tbodyElement.appendChild(trElement) |
| 96 | }) |
| 97 | |
| 98 | // Render pagination |
| 99 | const paginationElement = document.createElement('div') |
| 100 | paginationElement.classList.add('flex', 'items-center', 'gap-2') |
| 101 | |
| 102 | // Render pagination first page button |
| 103 | const firstPageButton = document.createElement('button') |
| 104 | firstPageButton.classList.add('border', 'rounded', 'p-1') |
no test coverage detected
searching dependent graphs…