()
| 18 | import { makeData, Person } from './makeData' |
| 19 | |
| 20 | function App() { |
| 21 | const rerender = React.useReducer(() => ({}), {})[1] |
| 22 | |
| 23 | const columns = React.useMemo<ColumnDef<Person>[]>( |
| 24 | () => [ |
| 25 | { |
| 26 | accessorKey: 'firstName', |
| 27 | header: ({ table }) => ( |
| 28 | <> |
| 29 | <IndeterminateCheckbox |
| 30 | {...{ |
| 31 | checked: table.getIsAllRowsSelected(), |
| 32 | indeterminate: table.getIsSomeRowsSelected(), |
| 33 | onChange: table.getToggleAllRowsSelectedHandler(), |
| 34 | }} |
| 35 | />{' '} |
| 36 | <button |
| 37 | {...{ |
| 38 | onClick: table.getToggleAllRowsExpandedHandler(), |
| 39 | }} |
| 40 | > |
| 41 | {table.getIsAllRowsExpanded() ? '👇' : '👉'} |
| 42 | </button>{' '} |
| 43 | First Name |
| 44 | </> |
| 45 | ), |
| 46 | cell: ({ row, getValue }) => ( |
| 47 | <div |
| 48 | style={{ |
| 49 | // Since rows are flattened by default, |
| 50 | // we can use the row.depth property |
| 51 | // and paddingLeft to visually indicate the depth |
| 52 | // of the row |
| 53 | paddingLeft: `${row.depth * 2}rem`, |
| 54 | }} |
| 55 | > |
| 56 | <div> |
| 57 | <IndeterminateCheckbox |
| 58 | {...{ |
| 59 | checked: row.getIsSelected(), |
| 60 | indeterminate: row.getIsSomeSelected(), |
| 61 | onChange: row.getToggleSelectedHandler(), |
| 62 | }} |
| 63 | />{' '} |
| 64 | {row.getCanExpand() ? ( |
| 65 | <button |
| 66 | {...{ |
| 67 | onClick: row.getToggleExpandedHandler(), |
| 68 | style: { cursor: 'pointer' }, |
| 69 | }} |
| 70 | > |
| 71 | {row.getIsExpanded() ? '👇' : '👉'} |
| 72 | </button> |
| 73 | ) : ( |
| 74 | '🔵' |
| 75 | )}{' '} |
| 76 | {getValue<boolean>()} |
| 77 | </div> |
nothing calls this directly
no test coverage detected