{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reorderable",
  "title": "Reorderable",
  "description": "A list the user puts in order: recipe steps, a queue, favorites.",
  "registryDependencies": [
    "@ouro/lib-announce",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-spring",
    "@ouro/lib-touch-target",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-drag",
    "@ouro/lib-use-reduced-motion",
    "@ouro/menu"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/reorderable/reorderable-styles.ts",
      "content": "export { contentClass, dropIndex, EDGE, edgeSpeed, fillLabel, handleClass, itemClass, listClass, MAX_FRAME, MAX_SPEED, moveItem, rootClass, scrollParent };\n\n// Class strings, values and helpers for Reorderable, apart from the component so its file\n// exports only components (React Fast Refresh). Class strings are literal so the app's\n// Tailwind finds them when it compiles.\n\n/** How near the scrolling area's top or bottom edge, in px, a dragging pointer starts to scroll it. @internal */\nconst EDGE = 56;\n\n/**\n * The fastest a drag scrolls, in px per millisecond, with the pointer at the edge or past it: 840px a second. @internal\n *\n * @claim \"The fastest a drag scrolls, in\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > has helpers that place, move and scroll)\n * @claim \"The fastest a drag scrolls, in\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:fileLine(registry/ouro/components/ouro/reorderable/reorderable.test.tsx, /expect\\(MAX_SPEED\\s\\*\\s1000\\)\\.toBe\\(840\\)/)\n */\nconst MAX_SPEED = 0.84;\n\n/** The longest a frame counts for when a drag scrolls, in ms: a frame after a pause does not jump. @internal */\nconst MAX_FRAME = 50;\n\n/** @internal */\nconst rootClass = \"min-w-0\";\n\n/** The list. While a row is dragged, text is not selected. @internal */\nconst listClass = \"group/reorder m-0 flex min-w-0 list-none flex-col p-0 data-dragging:select-none\";\n\n/**\n * One row: the handle, then the content. It is at least 44px tall on a touch screen, so\n * the handles' touch targets never overlap. While another row is dragged it slides out of\n * the way (it jumps with reduced motion); the dragged row follows the pointer above the\n * others, and a row picked up from the keyboard is outlined. A dropped row stays above\n * the others while it springs into its place; the component writes each row's `transform`.\n *\n * @internal\n * @claim \"It is at least 44px tall on a touch screen\" registry/ouro/components/ouro/reorderable/reorderable-styles.ts verify:fileLine(registry/ouro/components/ouro/reorderable/reorderable-styles.ts, /pointer-coarse:min-h-11/)\n * @claim \"A dropped row stays above the\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > with a pointer > springs a dropped row into its place with the speed it was let go at, and a row still sliding out of its way with none)\n * @claim \"A dropped row stays above the\" registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx::Reorderable on a phone > springs the dropped row into its place from under the finger, frame by frame)\n */\nconst itemClass =\n  \"relative m-0 flex min-w-0 list-none items-center gap-2 p-0 pointer-coarse:min-h-11 \" +\n  \"motion-safe:group-data-dragging/reorder:[&:not([data-dragging])]:[transition:transform_var(--ouro-duration-base)_var(--ouro-ease-out)] \" +\n  \"data-dragging:z-10 data-dragging:rounded-ouro-lg data-dragging:bg-background data-dragging:shadow-(--shadow-lg) \" +\n  \"data-dropped:z-10 data-dropped:rounded-ouro-lg data-dropped:bg-background \" +\n  \"data-grabbed:rounded-ouro-lg data-grabbed:outline-2 data-grabbed:outline-ring data-grabbed:outline-solid\";\n\n/**\n * The row's content. No `touch-action`: a touch that starts here scrolls the page. @internal\n *\n * @claim \"No `touch-action`: a touch that starts\" registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx::Reorderable on a phone > lets a touch that starts on a row, outside its handle, scroll the page)\n */\nconst contentClass = \"min-w-0 flex-1\";\n\n/**\n * The drag handle: a quiet grip button. `touch-none` keeps a touch that starts on it for\n * the drag instead of the page's scroll; `TouchTarget` makes it 44px to touch. While the list\n * is disabled (`aria-disabled`) it is dimmed, takes no hover or press, lets a touch scroll the\n * page, and is GrayText under forced colours.\n *\n * @claim \"While the list is disabled\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > disabled > draws a disabled handle in GrayText under forced colours) verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > disabled > takes no drag, no menu and no pick-up, and keeps its handles focusable and marked unavailable)\n * @claim \"While the list is disabled\" registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx::Reorderable on a phone > takes no tap and no drag on a disabled handle, whose touch scrolls the page instead)\n *\n * @internal\n * @claim \"`touch-none` keeps a touch that starts\" registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx::Reorderable on a phone > moves a row with a touch drag on its handle, without scrolling the page)\n * @claim \"`touch-none` keeps a touch that starts\" registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx::Reorderable on a phone > lets a touch that starts on a row, outside its handle, scroll the page)\n */\nconst handleClass =\n  \"press relative m-0 box-border inline-flex size-8 shrink-0 cursor-grab touch-none select-none items-center justify-center rounded-ouro-md border-0 \" +\n  \"forced-colors:border forced-colors:border-solid bg-transparent p-0 text-muted-foreground [-webkit-tap-highlight-color:transparent] \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid \" +\n  \"not-aria-disabled:pointer-fine:hover:bg-accent not-aria-disabled:pointer-fine:hover:text-accent-foreground active:cursor-grabbing data-grabbed:bg-accent data-grabbed:text-accent-foreground \" +\n  \"motion-safe:not-aria-disabled:active:scale-(--ouro-press-scale) active:duration-(--ouro-duration-fast) \" +\n  \"aria-disabled:cursor-not-allowed aria-disabled:touch-auto aria-disabled:opacity-50 forced-colors:aria-disabled:text-[GrayText]\";\n\n/**\n * Fills a label template: `{label}` is the row's label, `{n}` its 1-based position and\n * `{total}` the number of rows.\n *\n * @internal\n * @claim \"Fills a label template: `{label}` is\" registry/ouro/components/ouro/reorderable/reorderable-styles.ts verify:fileLine(registry/ouro/components/ouro/reorderable/reorderable-styles.ts, /replaceAll\\(\"\\{label\\}\",\\slabel\\)\\.replaceAll\\(\"\\{n\\}\",\\sString\\(n\\)\\)/)\n * @claim \"Fills a label template: `{label}` is\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > speaks and names with the labels the app passes)\n */\nfunction fillLabel(template: string, label: string, n: number, total: number): string {\n  return template.replaceAll(\"{label}\", label).replaceAll(\"{n}\", String(n)).replaceAll(\"{total}\", String(total));\n}\n\n/** A copy of `list` with the entry at `from` moved to `to`. @internal */\nfunction moveItem<T>(list: readonly T[], from: number, to: number): T[] {\n  const next = [...list];\n  next.splice(to, 0, ...next.splice(from, 1));\n  return next;\n}\n\n/**\n * Where the row dragged from `from` would land with its center at `center`: the number of\n * other rows it now sits after. It passes a row when its center reaches that row's center\n * (where the row rests), from either side, so a row dragged to the very end of the list\n * lands last.\n *\n * @internal\n */\nfunction dropIndex(centers: readonly number[], from: number, center: number): number {\n  return centers.filter((other, index) => index !== from && (index > from ? other <= center : other < center)).length;\n}\n\n/**\n * How fast to scroll, in px per millisecond, with the pointer at `y` between the scrolling\n * area's `top` and `bottom`: not at all in the middle, faster the nearer an edge, negative\n * toward the top. The caller multiplies by the frame's time, so the speed is the same at\n * 60Hz and at 120Hz.\n *\n * @internal\n * @claim \"How fast to scroll, in px\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > with a pointer > scrolls a list that scrolls in place while the pointer is held near its bottom edge, then near its top)\n * @claim \"How fast to scroll, in px\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > has helpers that place, move and scroll)\n * @claim \"The caller multiplies by the frame's\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > with a pointer > scrolls a list that scrolls in place while the pointer is held near its bottom edge, then near its top)\n */\nfunction edgeSpeed(y: number, top: number, bottom: number): number {\n  const near = (distance: number) => Math.min(Math.max((EDGE - distance) / EDGE, 0), 1) * MAX_SPEED;\n  return near(bottom - y) - near(y - top);\n}\n\n/**\n * The nearest ancestor of `element` (or `element` itself) that scrolls vertically, or the\n * page's scrolling element.\n *\n * @internal\n */\nfunction scrollParent(element: HTMLElement): HTMLElement {\n  for (let node: HTMLElement | null = element; node && node !== document.body && node !== document.documentElement; node = node.parentElement) {\n    const { overflowY } = getComputedStyle(node);\n    if ((overflowY === \"auto\" || overflowY === \"scroll\") && node.scrollHeight > node.clientHeight) return node;\n  }\n  return document.documentElement;\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/reorderable/reorderable-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/reorderable/reorderable.tsx",
      "content": "\"use client\";\n\nimport {\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useRef,\n  useState,\n  type FocusEvent as ReactFocusEvent,\n  type JSX,\n  type KeyboardEvent as ReactKeyboardEvent,\n  type MouseEvent as ReactMouseEvent,\n  type PointerEvent as ReactPointerEvent,\n  type ReactNode,\n} from \"react\";\nimport { announce } from \"@/registry/ouro/lib/ouro/announce\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { rubberband, spring, type SpringHandle } from \"@/registry/ouro/lib/ouro/spring\";\nimport { TouchTarget } from \"@/registry/ouro/lib/ouro/touch-target\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useDrag } from \"@/registry/ouro/lib/ouro/use-drag\";\nimport { useReducedMotion } from \"@/registry/ouro/lib/ouro/use-reduced-motion\";\nimport { Menu } from \"@/registry/ouro/components/ouro/menu/menu\";\nimport {\n  contentClass,\n  dropIndex,\n  edgeSpeed,\n  fillLabel,\n  handleClass,\n  itemClass,\n  listClass,\n  MAX_FRAME,\n  moveItem,\n  rootClass,\n  scrollParent,\n} from \"@/registry/ouro/components/ouro/reorderable/reorderable-styles\";\n\n/** One row of a `Reorderable`. */\nexport interface ReorderableItem {\n  /** Identifies the row; `onReorder` reports the new order as these ids. Unique in the list. */\n  id: string;\n  /** Names the row for its handle (\"Reorder Sear the ribs\") and in announcements. It is the row's content too, unless you pass `content`. */\n  label: string;\n  /** What the row shows, in place of the label: an `Item`, or any content. */\n  content?: ReactNode;\n}\n\n/**\n * The move `onReorder` reports: the row's id and its position before and after, counting from 0.\n *\n * @claim \"The move `onReorder` reports: the row's\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > drops a row in place without reporting when it did not move)\n * @claim \"The move `onReorder` reports: the row's\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > picks a row up with Space, moves it with the arrows, drops it with Space, and announces each step with its position)\n */\nexport interface ReorderableMove {\n  id: string;\n  from: number;\n  to: number;\n}\n\n/** Props for {@link Reorderable}. */\nexport interface ReorderableProps {\n  /**\n   * Names the list for screen readers, such as \"Steps\". It is always required.\n   *\n   * @claim \"It is always required\" registry/ouro/components/ouro/reorderable/reorderable.test-d.ts verify:fileLine(registry/ouro/components/ouro/reorderable/reorderable.test-d.ts, /\\{\\sitems:\\s\\[\\]\\s\\}>\\(\\)\\.not\\.toExtend<ReorderableProps>/)\n   */\n  label: string;\n  /** The rows, in order: `{ id, label, content }`. Pass them in a new order to change the order from outside. */\n  items: readonly ReorderableItem[];\n  /**\n   * Called once when the user drops a row in a new place, or moves it from its handle's\n   * menu, with every id in the new order and the move. The list already shows the new\n   * order; save it, or keep it in state.\n   * @claim \"Called once when the user drops\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the handle's menu, with no drag > opens a menu of moves on a click of the handle; a move is done at once, announced and reported)\n   * @claim \"Called once when the user drops\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > drops a row in place without reporting when it did not move)\n   */\n  onReorder?: ((ids: string[], move: ReorderableMove) => void) | undefined;\n  /**\n   * Each handle's accessible name; `{label}` is the row's label. @default \"Reorder {label}\"\n   *\n   * @claim \"Each handle's accessible name; `{label}` is\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > renders a named list of rows, each with a handle that says how to use it)\n   * @claim \"Each handle's accessible name; `{label}` is\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > speaks and names with the labels the app passes)\n   */\n  handleLabel?: string | undefined;\n  /**\n   * How to use a handle from the keyboard, read after its name.\n   * @default \"Press Enter for a menu of moves. Press Space to pick up, then use the arrow keys to move, Space to drop, and Escape to cancel.\"\n   */\n  instructionsLabel?: string | undefined;\n  /**\n   * Read after a handle's name, in place of the instructions, while its row is picked up\n   * from the keyboard.\n   * @default \"Picked up. Use the arrow keys to move, Space to drop, and Escape to cancel.\"\n   */\n  heldLabel?: string | undefined;\n  /** The item of a handle's menu that moves the row up one place. @default \"Move up\" */\n  moveUpLabel?: string | undefined;\n  /** The item of a handle's menu that moves the row down one place. @default \"Move down\" */\n  moveDownLabel?: string | undefined;\n  /** The item of a handle's menu that moves the row to the start of the list. @default \"Move to top\" */\n  moveToTopLabel?: string | undefined;\n  /** The item of a handle's menu that moves the row to the end of the list. @default \"Move to bottom\" */\n  moveToBottomLabel?: string | undefined;\n  /** The item that closes a handle's menu on a phone, where it is a bottom sheet. @default \"Close\" */\n  closeLabel?: string | undefined;\n  /** Announced when a row is picked up; `{label}`, `{n}` (its position) and `{total}` are filled in. @default \"{label} picked up. Position {n} of {total}.\" */\n  pickedUpLabel?: string | undefined;\n  /**\n   * Announced on each move, with the arrow keys or from a handle's menu. @default \"{label} moved. Position {n} of {total}.\"\n   *\n   * @claim \"Announced on each move, with the\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the handle's menu, with no drag > opens a menu of moves on a click of the handle; a move is done at once, announced and reported)\n   * @claim \"Announced on each move, with the\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > opens the menu of moves on an arrow key, and moves the row with one only once it is picked up)\n   */\n  movedLabel?: string | undefined;\n  /** Announced when a row is dropped. @default \"{label} dropped. Position {n} of {total}.\" */\n  droppedLabel?: string | undefined;\n  /** Announced when a move is cancelled and the row goes back. @default \"{label} put back. Position {n} of {total}.\" */\n  canceledLabel?: string | undefined;\n  /**\n   * Stops reordering, for example while a save of the last move is in flight: no drag, no\n   * menu of moves, no pick-up with Space. The handles stay in the tab order, marked\n   * `aria-disabled`, so focus stays where it is and a screen reader says they are unavailable.\n   * A row held from the keyboard or dragged when it turns on is put back, and an open menu\n   * closes.\n   * @claim \"Stops reordering, for example while a\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > disabled > takes no drag, no menu and no pick-up, and keeps its handles focusable and marked unavailable)\n   * @claim \"A row held from the keyboard\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > disabled > puts back a row held from the keyboard and closes an open menu when it turns on)\n   * @claim \"A row held from the keyboard\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > disabled > puts back a row being dragged when it turns on, and reports nothing)\n   */\n  disabled?: boolean | undefined;\n  /** Layout only: margins, or a height with `overflow-auto` (`max-h-80 overflow-auto`) to scroll the list in place. Appearance classes warn in development. */\n  className?: string | undefined;\n\n  /** Not a prop. Ouro UI uses `items`: `items={steps.map((step) => ({ id: step.id, label: step.title }))}`. */\n  values?: { \"Use items={[{ id, label, content }]}\": never };\n  /** Not a prop. Rows are data, with their content in `content`: `items={[{ id: \"1\", label: \"Sear\", content: <Item title=\"Sear\" /> }]}`. */\n  children?: { \"Use items={[{ id, label, content: <Item ... /> }]}\": never };\n  /**\n   * Not a prop. Each row's `content` is what it shows: `items={[{ id: \"1\", label: \"Sear\", content: <Item title=\"Sear\" /> }]}`.\n   *\n   * @claim \"Each row's `content` is what it\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > shows a row's label when it has no content)\n   */\n  renderItem?: { \"Use items={[{ id, label, content: <Item ... /> }]}\": never };\n  /** Not a prop. Ouro UI uses `onReorder`: `onReorder={(ids) => save(ids)}`. */\n  onChange?: { \"Use onReorder={(ids) => save(ids)}\": never };\n  /** Not a prop. Ouro UI uses `onReorder`: `onReorder={(ids) => save(ids)}`. */\n  onDragEnd?: { \"Use onReorder={(ids) => save(ids)}\": never };\n  /** Not a prop. Reorderable is a vertical list. */\n  axis?: { \"Reorderable is a vertical list; remove axis\": never };\n}\n\nconst itemsFix = 'items={[{ id: \"1\", label: \"Sear the ribs\", content: <Item title=\"Sear the ribs\" /> }]}';\nconst reorderFix = \"onReorder={(ids) => save(ids)}\";\n\n/** A pointer drag in progress. */\ninterface Drag {\n  id: string;\n  /** Where the row was in the order when the drag began. */\n  from: number;\n  row: HTMLElement;\n  rows: HTMLElement[];\n  /** The centers of the rows' places, in the viewport, when the drag began. */\n  centers: number[];\n  /** How far a passed row moves to make room. */\n  shift: number;\n  maxScroll: number;\n  /** The pointer's place in the viewport, and how far it has moved from where it pressed. */\n  y: number;\n  moved: number;\n  /** How far the dragged row is from its place, and the place it would drop in. */\n  delta: number;\n  to: number;\n  frame: number;\n  /** When the last frame ran, and the part of a px it did not scroll. */\n  time: number;\n  carry: number;\n  place: () => void;\n  stop: () => void;\n}\n\nfunction GripIcon(): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"currentColor\" className=\"size-4\">\n      <circle cx=\"5.5\" cy=\"3.5\" r=\"1.25\" />\n      <circle cx=\"10.5\" cy=\"3.5\" r=\"1.25\" />\n      <circle cx=\"5.5\" cy=\"8\" r=\"1.25\" />\n      <circle cx=\"10.5\" cy=\"8\" r=\"1.25\" />\n      <circle cx=\"5.5\" cy=\"12.5\" r=\"1.25\" />\n      <circle cx=\"10.5\" cy=\"12.5\" r=\"1.25\" />\n    </svg>\n  );\n}\n\n/**\n * A list the user puts in order: recipe steps, a queue, favorites. Each row has a drag\n * handle, a 44px target on a touch screen. Dragging it moves the row with the pointer, the\n * other rows make room, and holding it near the top or bottom edge scrolls the list or\n * the page. Let go and the row drops into the gap the others made for it, springing there\n * from where it was, and it can be picked up again on the way. A touch that starts\n * anywhere else on a row scrolls as usual.\n *\n * Dragging is never the only way. A tap or click on a handle, Enter, or a screen reader's\n * activation opens a menu with Move up, Move down, Move to top and Move to bottom; the\n * ones that cannot apply are disabled. From the keyboard, Space on a handle also picks the\n * row up: the up and down arrow keys move it, Space drops it and Escape cancels, which\n * puts it back. Moving focus away drops it where it is. Every move is announced to screen\n * readers with the row's position (\"Sear the ribs moved. Position 3 of 7.\"), and each\n * spoken string and menu item is a prop with an English default.\n *\n * The list shows the new order at once and keeps it; `onReorder` reports it, once per\n * drop. With reduced motion the other rows jump out of the way instead of sliding, and a\n * dropped row is in its place at once.\n *\n * Use `ItemGroup` instead for a list whose order the user does not change, and\n * `Resizable` to change sizes, not order.\n *\n * @group Lists\n * @see https://ui.ouroboros.bot/docs/reorderable\n *\n * @example\n * <Reorderable\n *   label=\"Steps\"\n *   items={steps.map((step) => ({ id: step.id, label: step.title, content: <Item title={step.title} description={step.text} /> }))}\n *   onReorder={(ids) => setSteps(ids.map((id) => steps.find((step) => step.id === id)!))}\n * />\n * @claim \"Every move is announced to screen\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the handle's menu, with no drag > opens a menu of moves on a click of the handle; a move is done at once, announced and reported)\n * @claim \"Each row has a drag handle\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the handle's menu, with no drag > moves a row to the top and to the bottom, and disables the moves that cannot apply)\n * @claim \"Every move is announced to screen\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > says the position again at either end instead of moving)\n * @claim \"Dragging is never the only way\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the handle's menu, with no drag > opens a menu of moves on a click of the handle; a move is done at once, announced and reported)\n * @claim \"Dragging is never the only way\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > picks a row up with Space, moves it with the arrows, drops it with Space, and announces each step with its position)\n * @claim \"), and each spoken string and menu item\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > speaks and names with the labels the app passes)\n * @claim \"), and each spoken string and menu item\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the keyboard > picks a row up with Space, moves it with the arrows, drops it with Space, and announces each step with its position)\n */\nexport function Reorderable(props: ReorderableProps): JSX.Element {\n  const {\n    label,\n    items,\n    onReorder,\n    handleLabel = \"Reorder {label}\",\n    instructionsLabel = \"Press Enter for a menu of moves. Press Space to pick up, then use the arrow keys to move, Space to drop, and Escape to cancel.\",\n    heldLabel = \"Picked up. Use the arrow keys to move, Space to drop, and Escape to cancel.\",\n    moveUpLabel = \"Move up\",\n    moveDownLabel = \"Move down\",\n    moveToTopLabel = \"Move to top\",\n    moveToBottomLabel = \"Move to bottom\",\n    closeLabel = \"Close\",\n    pickedUpLabel = \"{label} picked up. Position {n} of {total}.\",\n    movedLabel = \"{label} moved. Position {n} of {total}.\",\n    droppedLabel = \"{label} dropped. Position {n} of {total}.\",\n    canceledLabel = \"{label} put back. Position {n} of {total}.\",\n    disabled = false,\n    className,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    values,\n    children,\n    renderItem,\n    onChange,\n    onDragEnd,\n    axis,\n  } = props;\n  const reduced = useReducedMotion();\n\n  useAppearanceClassNameCheck(\n    \"Reorderable\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; style the content you give each row`\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Reorderable\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !label && [\"label is required; it names the list for screen readers\", '<Reorderable label=\"Steps\">'],\n          new Set(items.map((item) => item.id)).size !== items.length && [\n            \"two rows have the same id, so only the first shows\",\n            'give each row its own id: items={[{ id: \"1\", label: \"…\" }, { id: \"2\", label: \"…\" }]}',\n          ],\n          items.some((item) => !item.label) && [\"a row has no label; it names the row's handle\", '{ id: \"1\", label: \"Sear the ribs\" }'],\n          values !== undefined && [\"values is not a prop\", itemsFix],\n          children !== undefined && [\"children is not a prop; rows are data\", itemsFix],\n          renderItem !== undefined && [\"renderItem is not a prop; each row's content is in its item\", itemsFix],\n          onChange !== undefined && [\"onChange is not a prop\", reorderFix],\n          onDragEnd !== undefined && [\"onDragEnd is not a prop\", reorderFix],\n          axis !== undefined && [\"axis is not a prop; Reorderable is a vertical list\", '<Reorderable label=\"Steps\" items={…}>'],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  const byId = new Map<string, ReorderableItem>();\n  for (const item of items) if (!byId.has(item.id)) byId.set(item.id, item);\n  const ids = [...byId.keys()];\n  // The list keeps its own order until `items` arrive in another one (or with other rows).\n  const key = JSON.stringify(ids);\n  const [state, setState] = useState({ key, order: ids });\n  /** The row picked up from the keyboard, and the order to go back to on Escape. */\n  const [grab, setGrab] = useState<{ id: string; origin: string[] } | null>(null);\n  /** The row a pointer is dragging. */\n  const [dragging, setDragging] = useState<string | null>(null);\n  /** The row whose menu of moves is open. */\n  const [menu, setMenu] = useState<string | null>(null);\n  const current = state.key === key;\n  if (!current) {\n    setState({ key, order: ids });\n    if (grab) setGrab(null);\n    if (menu !== null) setMenu(null);\n  }\n  const order = current ? state.order : ids;\n  const grabbed = current ? grab : null;\n  const total = order.length;\n\n  const instructionsId = useId();\n  const heldId = useId();\n  const listRef = useRef<HTMLOListElement>(null);\n  /** The handle a pointer last pressed, and the drag it became. */\n  const pressed = useRef<string | null>(null);\n  const drag = useRef<Drag | undefined>(undefined);\n  /** Whether the last press on a handle became a drag, whose click is not an activation. */\n  const dragged = useRef(false);\n  /** The rows a press stopped on their way to rest: they go on if the press is only a tap. */\n  const caught = useRef<Array<{ row: HTMLElement; value: number; dropped: boolean }>>([]);\n  /**\n   * The row whose handle takes focus back after a move, once the move has painted: focusing it in\n   * the move's own commit would lay out the page there, and set a closing menu checking what in it\n   * can still take focus. It comes back from the handle's menu while the menu closes, or from the\n   * page when the move dropped it, and only while no other menu of the list has opened since, so a\n   * press that has moved on keeps its focus.\n   *\n   * @claim \"It comes back from the handle's menu while the menu closes, or from the page when the move dropped it, and only while no other menu of the list has opened since, so a press that has moved on keeps its focus.\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > from the handle's menu, with no drag > leaves focus where a press has moved it before the move painted: another row's menu, or a button)\n   */\n  const refocus = useRef<string | null>(null);\n  /** The row whose menu is open now, for a hand-back that waits for paint. */\n  const openMenu = useRef(menu);\n  useLayoutEffect(() => {\n    openMenu.current = menu;\n  });\n  useLayoutEffect(() => {\n    const id = refocus.current;\n    if (id === null) return;\n    refocus.current = null;\n    const handle = listRef.current!.children[order.indexOf(id)]!.querySelector(\"button\")!;\n    requestAnimationFrame(() => {\n      setTimeout(() => {\n        const active = document.activeElement as Element;\n        // Stryker disable next-line ConditionalExpression,EqualityOperator: focus is on the page here only in a browser that blurs a row React moves (Firefox); Chromium and WebKit, which the tests run in, keep it on the handle.\n        const dropped = active === document.body;\n        if (openMenu.current === null && (dropped || active.closest('[data-ouro=\"menu\"]') !== null)) handle.focus();\n      });\n    });\n  });\n\n  /**\n   * The springs carrying rows to rest after a drop, by row element. Each row carries `data-ouro-settling` while its spring runs.\n   *\n   * @claim \"Each row carries `data-ouro-settling` while its\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > with a pointer > moves the row with the pointer, makes room in the rows it passes, and reports the drop once)\n   */\n  const springs = useRef(new Map<HTMLElement, SpringHandle>());\n  /** Set by a drop for the layout effect that follows it: where each row was on screen, the dropped row and how it was let go. */\n  const dropped = useRef<{ tops: Map<HTMLElement, number>; row: HTMLElement; velocity: number; flick: boolean } | undefined>(undefined);\n\n  /** Puts a row `value` px below its place. Only that row's own `transform` changes. */\n  const shiftRow = (row: HTMLElement, value: number) => {\n    row.style.transform = value === 0 ? \"\" : `translateY(${value}px)`;\n  };\n  /** Keeps a row's spring, or forgets it, and marks the list as settling while any row is, for tests to wait on. The dropped row is marked for its style. */\n  const track = (row: HTMLElement, handle: SpringHandle | undefined, isDropped = false) => {\n    if (handle) springs.current.set(row, handle);\n    else springs.current.delete(row);\n    row.toggleAttribute(\"data-dropped\", isDropped);\n    listRef.current!.toggleAttribute(\"data-ouro-settling\", springs.current.size > 0);\n  };\n  /** Stops a row's spring where it is and returns how far the row is from its place. */\n  const holdRow = (row: HTMLElement) => {\n    const handle = springs.current.get(row);\n    if (!handle) return 0;\n    const { value } = handle.stop();\n    track(row, undefined);\n    shiftRow(row, value);\n    return value;\n  };\n  /** Springs a row from `from` px below its place into it, with the velocity it already has and a little bounce after a flick. */\n  const settleRow = (row: HTMLElement, from: number, velocity: number, flick: boolean, isDropped: boolean) => {\n    const handle = spring({\n      from,\n      to: 0,\n      velocity,\n      damping: flick ? 0.8 : 1,\n      reduced,\n      element: row,\n      onUpdate: (value) => shiftRow(row, value),\n      onRest: () => track(row, undefined),\n    });\n    // With reduced motion the spring was a jump, and the row is in its place already.\n    if (!handle.running) return;\n    // Until the first frame the row stays where it was on screen.\n    shiftRow(row, from);\n    track(row, handle, isDropped);\n  };\n\n  // After a drop the rows are in their new places in the list itself. Each one starts\n  // where it was on screen a moment ago and springs into its place. A list the app\n  // changed under the drag has nothing to spring from: its rows are simply there.\n  useLayoutEffect(() => {\n    const drop = dropped.current;\n    if (!drop) return;\n    dropped.current = undefined;\n    const rows = [...listRef.current!.children] as HTMLElement[];\n    for (const row of rows) {\n      holdRow(row);\n      shiftRow(row, 0);\n    }\n    for (const row of rows) {\n      const before = drop.tops.get(row);\n      const from = before === undefined ? 0 : before - row.getBoundingClientRect().top;\n      if (Math.abs(from) < 0.5) continue;\n      if (row === drop.row) settleRow(row, from, drop.velocity, drop.flick, true);\n      else settleRow(row, from, 0, false, false);\n    }\n  });\n\n  // A list unmounted mid-drag or mid-settle stops listening and moving.\n  useEffect(() => {\n    const running = springs.current;\n    return () => {\n      drag.current?.stop();\n      for (const handle of running.values()) handle.stop();\n    };\n  }, []);\n\n  const say = (template: string, id: string, index: number) => announce(fillLabel(template, byId.get(id)!.label, index + 1, total));\n\n  const drop = (held: { id: string; origin: string[] }) => {\n    const from = held.origin.indexOf(held.id);\n    const to = order.indexOf(held.id);\n    setGrab(null);\n    say(droppedLabel, held.id, to);\n    if (to !== from) onReorder?.(order, { id: held.id, from, to });\n  };\n\n  /** A move chosen from a handle's menu: done at once, announced and reported. */\n  const moveTo = (id: string, to: number) => {\n    const from = order.indexOf(id);\n    const next = moveItem(order, from, to);\n    // Focus goes back to the handle from the closing menu once the move has painted.\n    refocus.current = id;\n    setState({ key, order: next });\n    say(movedLabel, id, to);\n    onReorder?.(next, { id, from, to });\n  };\n\n  /** Puts a row held from the keyboard back where it was picked up. */\n  const putBack = (held: { id: string; origin: string[] }) => {\n    refocus.current = held.id;\n    setState({ key, order: held.origin });\n    setGrab(null);\n    say(canceledLabel, held.id, held.origin.indexOf(held.id));\n  };\n\n  const onClick = (event: ReactMouseEvent<HTMLButtonElement>, id: string) => {\n    if (disabled) return;\n    // The pointer's click that ends a drag is not an activation. A click from the keyboard\n    // or a screen reader (`detail` 0) always is, except while a pointer is dragging.\n    if (dragging !== null || (dragged.current && event.detail !== 0)) return;\n    // A row picked up from the keyboard is dropped by any other activation of its handle.\n    if (grabbed?.id === id) return drop(grabbed);\n    // A tap, a click, Enter or a screen reader's activation: the menu of moves, which needs no drag.\n    setMenu(menu === id ? null : id);\n  };\n\n  const onKeyDown = (event: ReactKeyboardEvent<HTMLButtonElement>, id: string) => {\n    // Nothing to pick up or open; the Space that comes up clicks nothing (onKeyUp).\n    if (disabled) return;\n    if (event.key === \" \") {\n      // Space picks the row up and drops it. Its click would open the menu instead.\n      event.preventDefault();\n      if (event.repeat) return;\n      if (grabbed?.id === id) return drop(grabbed);\n      setGrab({ id, origin: order });\n      say(pickedUpLabel, id, order.indexOf(id));\n      return;\n    }\n    if (grabbed?.id !== id) {\n      // As on any menu button, an arrow key opens the menu of moves.\n      if (event.key === \"ArrowUp\" || event.key === \"ArrowDown\") setMenu(id);\n      return;\n    }\n    if (event.key === \"ArrowUp\" || event.key === \"ArrowDown\") {\n      // The arrow moves the row, not the page.\n      event.preventDefault();\n      const from = order.indexOf(id);\n      const to = Math.min(Math.max(from + (event.key === \"ArrowUp\" ? -1 : 1), 0), total - 1);\n      if (to !== from) {\n        refocus.current = id;\n        setState({ key, order: moveItem(order, from, to) });\n      }\n      // At either end the position is said again, so the user hears why nothing moved.\n      say(movedLabel, id, to);\n    } else if (event.key === \"Escape\") {\n      // This Escape puts the row back; it does not also close a Dialog or Sheet around the list.\n      event.preventDefault();\n      event.stopPropagation();\n      putBack(grabbed);\n    }\n  };\n\n  const onKeyUp = (event: ReactKeyboardEvent<HTMLButtonElement>) => {\n    // A button clicks when Space comes up; this Space has done its work.\n    if (event.key === \" \") event.preventDefault();\n  };\n\n  const onBlur = (_event: ReactFocusEvent<HTMLButtonElement>, id: string) => {\n    // Focus that left because React moved the row comes straight back; focus the user moved drops the row where it is.\n    if (grabbed?.id === id && refocus.current === null) drop(grabbed);\n  };\n\n  /** Ends the drag: the rows spring to rest, and a drop in a new place is reported. The velocity only feeds the dropped row's spring. */\n  const finish = (commit: boolean, velocity: number, flick: boolean) => {\n    const held = drag.current!;\n    held.stop();\n    setDragging(null);\n    const { id, from, row, to } = held;\n    const changed = order[from] !== id;\n    // The rows spring to rest from where they are on screen now.\n    dropped.current = { tops: new Map(changed ? [] : held.rows.map((other) => [other, other.getBoundingClientRect().top])), row, velocity, flick };\n    // The app changed the rows under the drag: there is nothing to report.\n    if (changed) return;\n    // The row drops in the gap the others have made for it on screen, however fast it was let go.\n    if (commit && to !== from) {\n      const next = moveItem(order, from, to);\n      setState({ key, order: next });\n      say(droppedLabel, id, to);\n      onReorder?.(next, { id, from, to });\n    } else say(commit ? droppedLabel : canceledLabel, id, from);\n  };\n\n  const dragProps = useDrag({\n    axis: \"y\",\n    // The handle takes every touch (`touch-none`), so a sideways move is not a scroll.\n    crossAxis: \"ignore\",\n    onPress: () => {\n      // Rows still springing into place stop under the pointer, where they are.\n      caught.current = ([...listRef.current!.children] as HTMLElement[])\n        .filter((row) => springs.current.has(row))\n        .map((row) => ({ row, dropped: row.hasAttribute(\"data-dropped\"), value: holdRow(row) }));\n    },\n    onPressEnd: () => {\n      // Only a tap: the rows go on into their places.\n      for (const { row, value, dropped: isDropped } of caught.current.splice(0)) settleRow(row, value, 0, false, isDropped);\n    },\n    onStart: ({ event }) => {\n      const id = pressed.current!;\n      // Rows the press stopped on their way into place stay where they are: the dragged\n      // one is caught there, and from here the drag places the others.\n      const stopped = new Map(caught.current.splice(0).map(({ row, value }) => [row, value]));\n      dragged.current = true;\n      setMenu(null);\n      const list = listRef.current!;\n      const rows = [...list.children] as HTMLElement[];\n      const from = order.indexOf(id);\n      const row = rows[from]!;\n      // Each row's place is where it is on screen, less what it is still displaced by.\n      const rects = rows.map((other) => {\n        const displaced = stopped.get(other) ?? 0;\n        const rect = other.getBoundingClientRect();\n        return { top: rect.top - displaced, bottom: rect.bottom - displaced, height: rect.height, displaced };\n      });\n      const own = rects[from]!;\n      const first = rects[0]!;\n      const last = rects[rects.length - 1]!;\n      const scroller = scrollParent(list);\n      const escape = (pressedKey: KeyboardEvent) => {\n        if (pressedKey.key !== \"Escape\") return;\n        pressedKey.preventDefault();\n        pressedKey.stopPropagation();\n        finishRef.current(false, 0, false);\n      };\n      /**\n       * Each frame: scrolls while the pointer is near the top or bottom edge of what scrolls, by the time the frame took, so as fast on any screen.\n       *\n       * @claim \"Each frame: scrolls while the pointer\" registry/ouro/components/ouro/reorderable/reorderable.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.test.tsx::Reorderable > with a pointer > scrolls a list that scrolls in place while the pointer is held near its bottom edge, then near its top)\n       * @claim \"Each frame: scrolls while the pointer\" registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx verify:testExists(registry/ouro/components/ouro/reorderable/reorderable.touch.test.tsx::Reorderable on a phone > scrolls the page while the finger holds a row near the bottom edge, and drops it where it ends up)\n       */\n      const tick = (now: number) => {\n        const held = drag.current!;\n        const box = scroller === document.documentElement ? { top: 0, bottom: innerHeight } : scroller.getBoundingClientRect();\n        // A frame after a pause (a background tab) scrolls as one long frame, not as the whole pause.\n        const wanted = edgeSpeed(held.y, box.top, box.bottom) * Math.min(Math.max(now - held.time, 0), MAX_FRAME) + held.carry;\n        held.time = now;\n        // Whole px now; the rest waits for a later frame.\n        held.carry = wanted % 1;\n        // Only as far as it could scroll when the drag began: a row pulled past the end of the list must not make more to scroll into.\n        const next = Math.min(Math.max(scroller.scrollTop + Math.trunc(wanted), 0), held.maxScroll);\n        if (next !== scroller.scrollTop) {\n          scroller.scrollTop = next;\n          held.place();\n        }\n        held.frame = requestAnimationFrame(tick);\n      };\n      const held: Drag = {\n        id,\n        from,\n        row,\n        rows,\n        centers: rects.map((rect) => rect.top + rect.height / 2),\n        // Each passed row moves by the dragged row's height and the space between rows.\n        shift: own.height + (rects.length > 1 ? rects[1]!.top - first.bottom : 0),\n        maxScroll: scroller.scrollHeight - scroller.clientHeight,\n        y: event.clientY,\n        moved: 0,\n        delta: own.displaced,\n        to: from,\n        frame: requestAnimationFrame(tick),\n        time: event.timeStamp,\n        carry: 0,\n        /** Puts the dragged row under the pointer, where the pointer took hold of it, and the rows it has passed out of its way. */\n        place: () => {\n          const wanted = own.displaced + held.moved + scroller.scrollTop - startScroll;\n          // Past either end of the list the row resists instead of stopping dead.\n          const min = first.top - own.top;\n          const max = last.bottom - own.bottom;\n          const span = last.bottom - first.top;\n          held.delta = wanted < min ? min + rubberband(wanted - min, span) : wanted > max ? max + rubberband(wanted - max, span) : wanted;\n          held.to = dropIndex(held.centers, from, held.centers[from]! + held.delta);\n          rows.forEach((other, index) =>\n            shiftRow(other, index === from ? held.delta : from < index && index <= held.to ? -held.shift : held.to <= index && index < from ? held.shift : 0),\n          );\n        },\n        stop: () => {\n          document.removeEventListener(\"keydown\", escape, true);\n          cancelAnimationFrame(held.frame);\n          drag.current = undefined;\n        },\n      };\n      const startScroll = scroller.scrollTop;\n      document.addEventListener(\"keydown\", escape, true);\n      drag.current = held;\n      setDragging(id);\n    },\n    onMove: ({ delta, event }) => {\n      const held = drag.current;\n      // Escape ended the drag while the pointer was still down: its later moves are nobody's.\n      if (!held) return;\n      held.moved = delta;\n      held.y = event.clientY;\n      held.place();\n    },\n    onEnd: ({ velocity, flick, cancelled }) => {\n      if (drag.current) finish(!cancelled, cancelled ? 0 : velocity, !cancelled && flick);\n    },\n  });\n  // Escape is heard by a listener the drag attached once; it ends the drag with the latest render's rows.\n  const finishRef = useRef(finish);\n  useLayoutEffect(() => {\n    finishRef.current = finish;\n  });\n\n  // Turning disabled on puts back what is held, by the keyboard or a pointer, and closes a\n  // menu, before the browser paints.\n  const stop = useRef<(() => void) | undefined>(undefined);\n  useLayoutEffect(() => {\n    stop.current = () => {\n      if (drag.current) finish(false, 0, false);\n      if (grabbed) putBack(grabbed);\n      setMenu(null);\n    };\n  });\n  useLayoutEffect(() => {\n    // Stryker disable next-line ConditionalExpression: with disabled off nothing can be held or open (disabled refuses every pick-up), so stopping then changes nothing\n    if (disabled) stop.current!();\n  }, [disabled]);\n\n  const onPointerDown = (event: ReactPointerEvent<HTMLButtonElement>, id: string) => {\n    if (disabled) return;\n    if (event.button === 0 && event.isPrimary && !drag.current) {\n      // Keep the press from selecting text or starting a native drag.\n      event.preventDefault();\n      if (grabbed) drop(grabbed);\n      pressed.current = id;\n      dragged.current = false;\n    }\n    dragProps.onPointerDown(event);\n  };\n\n  return (\n    <div data-ouro=\"reorderable\" className={cn(rootClass, className)}>\n      <ol ref={listRef} role=\"list\" aria-label={label} data-ouro-reorderable-list=\"\" data-dragging={dragging !== null ? \"\" : undefined} className={listClass}>\n        {order.map((id) => {\n          const item = byId.get(id)!;\n          const index = order.indexOf(id);\n          return (\n            <li\n              key={id}\n              data-ouro-reorderable-item=\"\"\n              data-dragging={dragging === id ? \"\" : undefined}\n              data-grabbed={grabbed?.id === id ? \"\" : undefined}\n              className={itemClass}\n            >\n              <Menu\n                // The handle opens its menu itself, on a press that was not a drag; the menu only asks to close.\n                open={menu === id}\n                onOpenChange={(next) => {\n                  if (!next) setMenu(null);\n                }}\n                closeLabel={closeLabel}\n                // A menu on every row: holding the page would lay out and repaint all of it on each open and close.\n                modal={false}\n                trigger={\n                  <button\n                    ref={dragProps.ref}\n                    type=\"button\"\n                    data-ouro-reorderable-handle=\"\"\n                    data-ouro-control=\"reorderable\"\n                    data-ouro-part=\"handle\"\n                    aria-label={fillLabel(handleLabel, item.label, index + 1, total)}\n                    // A menu button, so no `aria-pressed`: a picked-up row is said by the announcer and by the handle's description.\n                    aria-describedby={disabled ? undefined : grabbed?.id === id ? heldId : instructionsId}\n                    aria-disabled={disabled || undefined}\n                    data-grabbed={grabbed?.id === id ? \"\" : undefined}\n                    className={handleClass}\n                    onClick={(event) => onClick(event, id)}\n                    onKeyDown={(event) => onKeyDown(event, id)}\n                    onKeyUp={onKeyUp}\n                    onBlur={(event) => onBlur(event, id)}\n                    onPointerDown={(event) => onPointerDown(event, id)}\n                    onPointerMove={dragProps.onPointerMove}\n                    onPointerUp={dragProps.onPointerUp}\n                    onPointerCancel={dragProps.onPointerCancel}\n                  >\n                    <TouchTarget />\n                    <GripIcon />\n                  </button>\n                }\n                items={[\n                  { label: moveUpLabel, disabled: index === 0, onClick: () => moveTo(id, index - 1) },\n                  { label: moveDownLabel, disabled: index === total - 1, onClick: () => moveTo(id, index + 1) },\n                  { label: moveToTopLabel, disabled: index === 0, onClick: () => moveTo(id, 0) },\n                  { label: moveToBottomLabel, disabled: index === total - 1, onClick: () => moveTo(id, total - 1) },\n                ]}\n              />\n              <div data-ouro-reorderable-content=\"\" className={contentClass}>\n                {item.content ?? item.label}\n              </div>\n            </li>\n          );\n        })}\n      </ol>\n      <span id={instructionsId} hidden>\n        {instructionsLabel}\n      </span>\n      <span id={heldId} hidden>\n        {heldLabel}\n      </span>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/reorderable/reorderable.tsx"
    }
  ],
  "docs": "A list the user puts in order: recipe steps, a queue, favorites. Import: import { Reorderable } from \"@/components/ouro/reorderable/reorderable\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: kbd, menu, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/reorderable.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}