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

Function Example

packages/@adobe/react-spectrum/test/table/TableDnd.test.js:1079–1130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1077
1078 it('should call onRootDrop when dropping on a empty table', async function () {
1079 function Example() {
1080 let columns = [
1081 {id: 'id', value: 'ID'},
1082 {id: 'name', value: 'Name'},
1083 {id: 'type', value: 'Type'}
1084 ];
1085
1086 let list1 = useListData({
1087 initialItems: []
1088 });
1089
1090 let list2 = useListData({
1091 initialItems: [
1092 {id: '7', type: 'folder', name: 'Pictures'},
1093 {id: '8', type: 'file', name: 'Adobe Fresco'},
1094 {id: '9', type: 'folder', name: 'Apps'},
1095 {id: '10', type: 'file', name: 'Adobe Illustrator'},
1096 {id: '11', type: 'file', name: 'Adobe Lightroom'},
1097 {id: '12', type: 'file', name: 'Adobe Dreamweaver'}
1098 ]
1099 });
1100
1101 let {dragAndDropHooks: table1Hooks} = useDragAndDrop({
1102 ...mockUtilityOptions,
1103 acceptedDragTypes: 'all'
1104 });
1105
1106 let {dragAndDropHooks: table2Hooks} = useDragAndDrop({
1107 getItems: keys =>
1108 [...keys].map(key => {
1109 let item = list2.getItem(key);
1110 return {
1111 [`${item.type}`]: JSON.stringify(item),
1112 'text/plain': JSON.stringify(item)
1113 };
1114 })
1115 });
1116
1117 return (
1118 <Flex wrap gap="size-300">
1119 <TableView
1120 aria-label="Droppable TableView"
1121 selectionMode="multiple"
1122 width="size-3600"
1123 height="size-3600"
1124 dragAndDropHooks={table1Hooks}>
1125 <TableHeader columns={columns}>
1126 {column => (
1127 <Column minWidth={100} isRowHeader={column.id === 'name'}>
1128 {column.name}
1129 </Column>
1130 )}
1131 </TableHeader>
1132 <TableBody items={list1.items}>
1133 {item => (

Callers

nothing calls this directly

Calls 3

useListDataFunction · 0.90
useDragAndDropFunction · 0.90
getItemMethod · 0.65

Tested by

no test coverage detected