| 1 |
import { useSortable } from "@dnd-kit/sortable"; |
| 2 |
import { CSS } from "@dnd-kit/utilities"; |
| 3 |
|
| 4 |
export function SortableItem({ sortId, children, initialOpen }) { |
| 5 |
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ |
| 6 |
id: sortId, |
| 7 |
disabled: initialOpen, |
| 8 |
}); |
| 9 |
|
| 10 |
const style = { |
| 11 |
transform: CSS.Transform.toString(transform), |
| 12 |
transition: transition, |
| 13 |
marginTop: "10px", |
| 14 |
}; |
| 15 |
|
| 16 |
return ( |
| 17 |
<div ref={setNodeRef} style={style} {...listeners} {...attributes}> |
| 18 |
{children} |
| 19 |
</div> |
| 20 |
); |
| 21 |
} |
| 22 |
|