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

Function ReorderableListView

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

Source from the content-addressed store, hash-verified

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