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

Function ReorderableListView

examples/s2-vite-project/src/App.tsx:103–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101];
102
103function ReorderableListView() {
104 let list = useListData({initialItems: listItems});
105 let {dragAndDropHooks} = useDragAndDrop({
106 getItems: keys =>
107 [...keys].map(key => {
108 let item = list.getItem(key)!;
109 return {'text/plain': item.name};
110 }),
111 onReorder(e) {
112 if (e.target.dropPosition === 'before') {
113 list.moveBefore(e.target.key, e.keys);
114 } else if (e.target.dropPosition === 'after') {
115 list.moveAfter(e.target.key, e.keys);
116 }
117 }
118 });
119 return (
120 <ListView
121 aria-label="Reorderable files"
122 selectionMode="multiple"
123 items={list.items}
124 dragAndDropHooks={dragAndDropHooks}
125 styles={style({width: 320, height: 320})}>
126 {(item: any) => (
127 <ListViewItem textValue={item.name}>
128 <Text>{item.name}</Text>
129 </ListViewItem>
130 )}
131 </ListView>
132 );
133}
134
135function ReorderableTableView() {
136 let list = useListData({initialItems: tableItems});

Callers

nothing calls this directly

Calls 3

useDragAndDropFunction · 0.90
useListDataFunction · 0.85
getItemMethod · 0.65

Tested by

no test coverage detected