'use client' import { Reorder, useDragControls, useReducedMotion } from 'framer-motion' import { GripVertical } from 'lucide-react' import type { ReactNode } from 'react' interface SortableRowProps { /** Identity used by Reorder to track this item across reorders. */ value: T /** The row's existing markup: rendered untouched beside the drag handle. */ children: ReactNode /** Localized aria-label for the drag handle. */ handleLabel: string /** Disable dragging (e.g. a single-row list). */ disabled?: boolean className?: string } /** * A drag-to-reorder row built on framer-motion's Reorder, with the grip handle * on the LEFT edge. The handle owns the drag (dragListener=false + * dragControls) so text inputs inside the row stay selectable. The handle is * vertically centered against the row so it reads correctly for both compact * text rows and tall product rows. Motion collapses to instant when the user * prefers reduced motion. * * Wrap the list in `` * and render one SortableRow per item; the row's own markup goes in `children`, * so callers don't have to restructure existing JSX. */ export function SortableRow({ value, children, handleLabel, disabled = false, className, }: SortableRowProps) { const controls = useDragControls() const reduceMotion = useReducedMotion() return (
{children}
) }