-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'adobe:main' into fix-ssr-on-react-18-strictmode
- Loading branch information
Showing
142 changed files
with
5,645 additions
and
3,411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Item, ListView, Text, useListData } from "@adobe/react-spectrum"; | ||
import { useDragAndDrop } from "@react-spectrum/dnd"; | ||
import Folder from "@spectrum-icons/illustrations/Folder"; | ||
|
||
export default function ReorderableListView() { | ||
let list = useListData({ | ||
initialItems: [ | ||
{ id: "1", type: "file", name: "Adobe Photoshop" }, | ||
{ id: "2", type: "file", name: "Adobe XD" }, | ||
{ id: "3", type: "folder", name: "Documents", childNodes: [] }, | ||
{ id: "4", type: "file", name: "Adobe InDesign" }, | ||
{ id: "5", type: "folder", name: "Utilities", childNodes: [] }, | ||
{ id: "6", type: "file", name: "Adobe AfterEffects" }, | ||
], | ||
}); | ||
|
||
// Append a generated key to the item type so they can only be reordered within this list and not dragged elsewhere. | ||
let { dragAndDropHooks } = useDragAndDrop({ | ||
getItems(keys) { | ||
return [...keys].map((key) => { | ||
let item = list.getItem(key); | ||
// Setup the drag types and associated info for each dragged item. | ||
return { | ||
"custom-app-type-reorder": JSON.stringify(item), | ||
"text/plain": item.name, | ||
}; | ||
}); | ||
}, | ||
acceptedDragTypes: ["custom-app-type-reorder"], | ||
onReorder: async (e) => { | ||
let { keys, target, dropOperation } = e; | ||
|
||
if (target.dropPosition === "before") { | ||
list.moveBefore(target.key, [...keys]); | ||
} else if (target.dropPosition === "after") { | ||
list.moveAfter(target.key, [...keys]); | ||
} | ||
}, | ||
getAllowedDropOperations: () => ["move"], | ||
}); | ||
|
||
return ( | ||
<ListView | ||
aria-label="Reorderable ListView" | ||
selectionMode="multiple" | ||
width="size-3600" | ||
height="size-3600" | ||
items={list.items} | ||
dragAndDropHooks={dragAndDropHooks} | ||
> | ||
{(item) => ( | ||
<Item textValue={item.name}> | ||
{item.type === "folder" && <Folder />} | ||
<Text>{item.name}</Text> | ||
</Item> | ||
)} | ||
</ListView> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.