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

Function Example

packages/@react-spectrum/s2/test/TableView.browser.test.tsx:80–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78 let onDragStart = vi.fn();
79 let onDragEnd = vi.fn();
80 function Example() {
81 let {dragAndDropHooks} = useDragAndDrop({
82 pointerDragSource: 'handle',
83 getItems: keys => [...keys].map(key => ({'text/plain': String(key)})),
84 onDragStart,
85 onDragEnd
86 });
87 return (
88 <div style={{width: 400}}>
89 <TableView aria-label="Source" dragAndDropHooks={dragAndDropHooks}>
90 <TableHeader>
91 <Column isRowHeader>Name</Column>
92 </TableHeader>
93 <TableBody>
94 <Row id="cat" textValue="Cat">
95 <Cell>Cat</Cell>
96 </Row>
97 </TableBody>
98 </TableView>
99 <DropZone onDrop={onDrop} onDropEnter={onDropEnter}>
100 Drop here
101 </DropZone>
102 </div>
103 );
104 }
105
106 await render(<Example />);
107 let button = page.getByRole('button', {name: /^Drag /});

Callers

nothing calls this directly

Calls 2

useDragAndDropFunction · 0.90
StringFunction · 0.85

Tested by

no test coverage detected