()
| 21 | } from '@tanstack/react-table' |
| 22 | |
| 23 | function App() { |
| 24 | const rerender = React.useReducer(() => ({}), {})[1] |
| 25 | |
| 26 | //table states |
| 27 | const [rowPinning, setRowPinning] = React.useState<RowPinningState>({ |
| 28 | top: [], |
| 29 | bottom: [], |
| 30 | }) |
| 31 | const [expanded, setExpanded] = React.useState<ExpandedState>({}) |
| 32 | |
| 33 | //demo states |
| 34 | const [keepPinnedRows, setKeepPinnedRows] = React.useState(true) |
| 35 | const [includeLeafRows, setIncludeLeafRows] = React.useState(true) |
| 36 | const [includeParentRows, setIncludeParentRows] = React.useState(false) |
| 37 | const [copyPinnedRows, setCopyPinnedRows] = React.useState(false) |
| 38 | |
| 39 | const columns = React.useMemo<ColumnDef<Person>[]>( |
| 40 | () => [ |
| 41 | { |
| 42 | id: 'pin', |
| 43 | header: () => 'Pin', |
| 44 | cell: ({ row }) => |
| 45 | row.getIsPinned() ? ( |
| 46 | <button |
| 47 | onClick={() => row.pin(false, includeLeafRows, includeParentRows)} |
| 48 | > |
| 49 | ❌ |
| 50 | </button> |
| 51 | ) : ( |
| 52 | <div style={{ display: 'flex', gap: '4px' }}> |
| 53 | <button |
| 54 | onClick={() => |
| 55 | row.pin('top', includeLeafRows, includeParentRows) |
| 56 | } |
| 57 | > |
| 58 | ⬆️ |
| 59 | </button> |
| 60 | <button |
| 61 | onClick={() => |
| 62 | row.pin('bottom', includeLeafRows, includeParentRows) |
| 63 | } |
| 64 | > |
| 65 | ⬇️ |
| 66 | </button> |
| 67 | </div> |
| 68 | ), |
| 69 | }, |
| 70 | { |
| 71 | accessorKey: 'firstName', |
| 72 | header: ({ table }) => ( |
| 73 | <> |
| 74 | <button |
| 75 | {...{ |
| 76 | onClick: table.getToggleAllRowsExpandedHandler(), |
| 77 | }} |
| 78 | > |
| 79 | {table.getIsAllRowsExpanded() ? '👇' : '👉'} |
| 80 | </button>{' '} |
nothing calls this directly
no test coverage detected