()
| 86 | ] |
| 87 | |
| 88 | function App() { |
| 89 | const [data, setData] = React.useState(() => makeData(30)) |
| 90 | const [columns] = React.useState(() => [...defaultColumns]) |
| 91 | |
| 92 | const rerender = () => setData(() => makeData(30)) |
| 93 | |
| 94 | const table = useReactTable({ |
| 95 | data, |
| 96 | columns, |
| 97 | getCoreRowModel: getCoreRowModel(), |
| 98 | debugTable: true, |
| 99 | debugHeaders: true, |
| 100 | debugColumns: true, |
| 101 | columnResizeMode: 'onChange', |
| 102 | }) |
| 103 | |
| 104 | const randomizeColumns = () => { |
| 105 | table.setColumnOrder( |
| 106 | faker.helpers.shuffle(table.getAllLeafColumns().map((d) => d.id)), |
| 107 | ) |
| 108 | } |
| 109 | |
| 110 | return ( |
| 111 | <div className="p-2"> |
| 112 | <div className="inline-block border border-black shadow rounded"> |
| 113 | <div className="px-1 border-b border-black"> |
| 114 | <label> |
| 115 | <input |
| 116 | {...{ |
| 117 | type: 'checkbox', |
| 118 | checked: table.getIsAllColumnsVisible(), |
| 119 | onChange: table.getToggleAllColumnsVisibilityHandler(), |
| 120 | }} |
| 121 | />{' '} |
| 122 | Toggle All |
| 123 | </label> |
| 124 | </div> |
| 125 | {table.getAllLeafColumns().map((column) => { |
| 126 | return ( |
| 127 | <div key={column.id} className="px-1"> |
| 128 | <label> |
| 129 | <input |
| 130 | {...{ |
| 131 | type: 'checkbox', |
| 132 | checked: column.getIsVisible(), |
| 133 | onChange: column.getToggleVisibilityHandler(), |
| 134 | }} |
| 135 | />{' '} |
| 136 | {column.id} |
| 137 | </label> |
| 138 | </div> |
| 139 | ) |
| 140 | })} |
| 141 | </div> |
| 142 | <div className="h-4" /> |
| 143 | <div className="flex flex-wrap gap-2"> |
| 144 | <button onClick={() => rerender()} className="border p-1"> |
| 145 | Regenerate |
nothing calls this directly
no test coverage detected