MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ReorderableTableView

Function ReorderableTableView

examples/s2-next-macros/src/app/page.tsx:140–178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138}
139
140function ReorderableTableView() {
141 let list = useListData({initialItems: tableItems});
142 let {dragAndDropHooks} = useDragAndDrop({
143 getItems: keys =>
144 [...keys].map(key => {
145 let item = list.getItem(key)!;
146 return {'text/plain': item.name};
147 }),
148 onReorder(e) {
149 if (e.target.dropPosition === 'before') {
150 list.moveBefore(e.target.key, e.keys);
151 } else if (e.target.dropPosition === 'after') {
152 list.moveAfter(e.target.key, e.keys);
153 }
154 }
155 });
156 return (
157 <TableView
158 aria-label="Reorderable files"
159 selectionMode="multiple"
160 dragAndDropHooks={dragAndDropHooks}
161 styles={style({width: 320, height: 320})}>
162 <TableHeader>
163 <Column isRowHeader>Name</Column>
164 <Column>Type</Column>
165 <Column>Date Modified</Column>
166 </TableHeader>
167 <TableBody items={list.items}>
168 {(item: any) => (
169 <Row id={item.id}>
170 <Cell>{item.name}</Cell>
171 <Cell>{item.type}</Cell>
172 <Cell>{item.modified}</Cell>
173 </Row>
174 )}
175 </TableBody>
176 </TableView>
177 );
178}
179
180function TreeItem({id, name, childItems}: TreeItemData) {
181 return (

Callers

nothing calls this directly

Calls 3

useDragAndDropFunction · 0.90
useListDataFunction · 0.85
getItemMethod · 0.65

Tested by

no test coverage detected