({items}: {items: RecordItem[]})
| 110 | } |
| 111 | |
| 112 | export function ReorderFixture({items}: {items: RecordItem[]}) { |
| 113 | let [rows, setRows] = useState(items); |
| 114 | let {dragAndDropHooks} = useDragAndDrop({ |
| 115 | getItems: keys => [...keys].map(key => ({'text/plain': String(key)})), |
| 116 | onReorder: ({keys, target}) => setRows(rows => moveRecords(rows, keys, target)) |
| 117 | }); |
| 118 | return ( |
| 119 | <GridList |
| 120 | aria-label="Reorderable records" |
| 121 | className="reorder-list" |
| 122 | items={rows} |
| 123 | dragAndDropHooks={dragAndDropHooks}> |
| 124 | {item => ( |
| 125 | <GridListItem id={item.id} data-record={item.id} textValue={item.name}> |
| 126 | <div className="reorder-content"> |
| 127 | <Button slot="drag" aria-label={`Drag ${item.name}`}> |
| 128 | ≡ |
| 129 | </Button> |
| 130 | <Text data-record-label>{item.name}</Text> |
| 131 | <Text slot="description"> |
| 132 | {item.owner} · {item.status} |
| 133 | </Text> |
| 134 | </div> |
| 135 | </GridListItem> |
| 136 | )} |
| 137 | </GridList> |
| 138 | ); |
| 139 | } |
nothing calls this directly
no test coverage detected