{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "extends": "none",
  "name": "list-box-rearrange-example",
  "title": "List Box Rearrange",
  "description": "list-box-rearrange-example",
  "dependencies": [
    "react-aria-components",
    "react-stately"
  ],
  "registryDependencies": [
    "https://intentui.com/r/list-box"
  ],
  "files": [
    {
      "path": "src/components/examples/collections/list-box/list-box-rearrange-example.tsx",
      "content": "\"use client\"\n\nimport { useDragAndDrop } from \"react-aria-components/useDragAndDrop\"\nimport { useListData } from \"react-stately/useListData\"\nimport { ListBox, ListBoxItem, ListBoxLabel } from \"@/components/ui/list-box\"\n\nexport default function ListBoxRearrangeDemo() {\n  const list = useListData({\n    initialItems: [\n      { id: \"1\", name: \"Nirvana\" },\n      { id: \"2\", name: \"Radiohead\" },\n      { id: \"3\", name: \"Foo Fighters\" },\n      { id: \"4\", name: \"Arctic Monkeys\" },\n      { id: \"5\", name: \"The Strokes\" },\n    ],\n  })\n\n  const { dragAndDropHooks } = useDragAndDrop({\n    getItems: (keys) =>\n      [...keys].map((key) => ({\n        \"text/plain\": list.getItem(key)?.name ?? \"\",\n      })),\n    onReorder(e) {\n      if (e.target.dropPosition === \"before\") {\n        list.moveBefore(e.target.key, e.keys)\n      } else if (e.target.dropPosition === \"after\") {\n        list.moveAfter(e.target.key, e.keys)\n      }\n    },\n  })\n\n  return (\n    <ListBox\n      className=\"max-w-2xs\"\n      items={list.items}\n      aria-label=\"Bands\"\n      selectionMode=\"multiple\"\n      dragAndDropHooks={dragAndDropHooks}\n    >\n      {(item) => (\n        <ListBoxItem textValue={item.name}>\n          <ListBoxLabel>{item.name}</ListBoxLabel>\n        </ListBoxItem>\n      )}\n    </ListBox>\n  )\n}\n",
      "type": "registry:page",
      "target": "app/list-box-rearrange-example/page.tsx"
    }
  ],
  "type": "registry:page"
}