// The non-drag way to reorder a list (WCAG 2.5.7, docs/DESIGN.md "Reordering"): anything a grip can // drag also moves by Top / Up / Down / Bottom — a menu's rows or a row of buttons, one rule for both. export type MoveTo = "top" | "up" | "down" | "bottom"; export const MOVES: readonly MoveTo[] = ["top", "up", "down", "bottom"]; /** Where `to` sends the item at `from` in a list of `count`, or null when it would not move (the * first item going up, the last going down, a stale index) — the caller shows that move as off. */ export function moveTarget(from: number, count: number, to: MoveTo): number | null { if (from < 0 || from >= count) return null; const at = to === "top" ? 0 : to === "bottom" ? count - 1 : to === "up" ? from - 1 : from + 1; return at === from || at < 0 || at >= count ? null : at; }