{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"kanban-board","type":"registry:component","title":"Kanban board","description":"Lift a card and the others slide aside to make room for it.","author":"Yash Bavadiya <https://xevrion.dev>","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"components/kanban-board.tsx","type":"registry:component","content":"\"use client\";\n\nimport {\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useRef,\n  useState,\n} from \"react\";\nimport {\n  AnimatePresence,\n  LayoutGroup,\n  MotionConfig,\n  animate,\n  motion,\n  motionValue,\n  useMotionValue,\n  useSpring,\n  useTransform,\n  useVelocity,\n  type MotionValue,\n  type Variants,\n} from \"motion/react\";\nimport { useReducedMotion } from \"@/hooks/use-reduced-motion\";\nimport { cn } from \"@/lib/utils\";\n\nexport type KanbanCard = { id: string; title: string };\nexport type KanbanColumn = { id: string; title: string; cards: KanbanCard[] };\n\n// Cards make room without overshooting: a slot that bounces reads as the\n// wrong drop position for a moment.\nconst LAYOUT = { type: \"spring\", duration: 0.3, bounce: 0 } as const;\nconst LIFT = { type: \"spring\", duration: 0.25, bounce: 0 } as const;\n// Critically damped (damping = 2 * sqrt(stiffness)): a released card glides\n// home carrying the hand's velocity and stops dead in its slot.\nconst HOME = { type: \"spring\", stiffness: 500, damping: 45 } as const;\n// Enough to read as picked up without the card outgrowing its column.\nconst LIFT_SCALE = 1.03;\n// Pointer speed (px/s) that reaches the full tilt, and that tilt in degrees.\nconst TILT_SPEED = 1000;\nconst TILT = 2;\n// Movement before a press becomes a drag, so a click still just focuses.\nconst DRAG_SLOP = 4;\n// Matches gap-2 between cards.\nconst GAP = 8;\n// Layered and transparent, so it darkens whatever is below. The 1px ring\n// keeps the lifted edge visible in dark mode, where shadows barely show.\nconst LIFTED_SHADOW = [\n  \"0 0 0 1px light-dark(oklch(0 0 0 / 0.06), oklch(1 0 0 / 0.08))\",\n  \"0 2px 4px light-dark(oklch(0 0 0 / 0.06), oklch(0 0 0 / 0.4))\",\n  \"0 12px 24px -6px light-dark(oklch(0 0 0 / 0.2), oklch(0 0 0 / 0.7))\",\n].join(\", \");\n\ntype CardValues = {\n  x: MotionValue<number>;\n  y: MotionValue<number>;\n  lift: MotionValue<number>;\n  rotate: MotionValue<number>;\n  z: MotionValue<number>;\n};\ntype Held = { id: string; mode: \"pointer\" | \"keyboard\"; before: KanbanColumn[] };\ntype Session = {\n  id: string;\n  pointerId: number;\n  startX: number;\n  startY: number;\n  // Where on the card it was grabbed, so it stays pinned under the pointer.\n  grabX: number;\n  grabY: number;\n  lastX: number;\n  lastY: number;\n  started: boolean;\n  stop: () => void;\n};\n\nconst makeValues = (): CardValues => ({\n  x: motionValue(0),\n  y: motionValue(0),\n  lift: motionValue(0),\n  rotate: motionValue(0),\n  z: motionValue(0),\n});\n\nconst clamp = (v: number, min: number, max: number) =>\n  Math.min(Math.max(v, min), max);\n\nfunction locate(columns: KanbanColumn[], id: string) {\n  const col = columns.findIndex((c) => c.cards.some((card) => card.id === id));\n  const index = col < 0 ? -1 : columns[col].cards.findIndex((c) => c.id === id);\n  return { col, index };\n}\n\nfunction moveCard(\n  columns: KanbanColumn[],\n  id: string,\n  toCol: number,\n  toIndex: number,\n) {\n  const { col, index } = locate(columns, id);\n  const card = columns[col].cards[index];\n  const next = columns.map((c) => ({\n    ...c,\n    cards: c.cards.filter((other) => other.id !== id),\n  }));\n  next[toCol].cards.splice(toIndex, 0, card);\n  return next;\n}\n\n/**\n * Drag cards within and between columns, or from the keyboard: Space picks\n * the focused card up, arrows move it, Space drops it and Escape puts it\n * back. Without a card held, the arrows move focus between cards.\n */\nexport function KanbanBoard({\n  columns,\n  onChange,\n  label,\n  className,\n}: {\n  columns: KanbanColumn[];\n  onChange: (columns: KanbanColumn[]) => void;\n  label: string;\n  className?: string;\n}) {\n  const reduceMotion = !!useReducedMotion();\n  const boardRef = useRef<HTMLDivElement>(null);\n  const slots = useRef(new Map<string, HTMLLIElement>());\n  const buttons = useRef(new Map<string, HTMLButtonElement>());\n  const lists = useRef<(HTMLUListElement | null)[]>([]);\n  const session = useRef<Session | null>(null);\n  const [held, setHeld] = useState<Held | null>(null);\n  const [focusId, setFocusId] = useState(columns[0]?.cards[0]?.id ?? \"\");\n  const [announcement, setAnnouncement] = useState(\"\");\n  const instructions = useId();\n  // Scopes layoutIds, so two boards on a page never trade cards.\n  const group = useId();\n\n  // One set per card that outlives remounts, since a card moving between\n  // columns is a new element in a new list.\n  const [values] = useState(\n    () =>\n      new Map(\n        columns.flatMap((c) => c.cards).map((card) => [card.id, makeValues()]),\n      ),\n  );\n  const valuesFor = (id: string) => {\n    let v = values.get(id);\n    if (!v) values.set(id, (v = makeValues()));\n    return v;\n  };\n\n  // Tilt follows the pointer's horizontal speed, smoothed so a jittery hand\n  // doesn't wobble the card.\n  const pointerX = useMotionValue(0);\n  const tiltTarget = useTransform(\n    useVelocity(pointerX),\n    [-TILT_SPEED, TILT_SPEED],\n    [-TILT, TILT],\n  );\n  const tilt = useSpring(tiltTarget, { stiffness: 400, damping: 30 });\n  // Only for the release velocity.\n  const pointerY = useMotionValue(0);\n  const release = useRef<{\n    id: string;\n    left: number;\n    top: number;\n    velocity: { x: number; y: number };\n  } | null>(null);\n\n  // For window listeners and callbacks that outlive the render that made them.\n  const latest = useRef({ columns, held, onChange });\n  useLayoutEffect(() => {\n    latest.current = { columns, held, onChange };\n  });\n\n  const title = (id: string, list = columns) =>\n    list.flatMap((c) => c.cards).find((c) => c.id === id)?.title ?? \"\";\n  const where = (id: string, list = columns) => {\n    const { col, index } = locate(list, id);\n    return `${list[col].title}, position ${index + 1} of ${list[col].cards.length}`;\n  };\n\n  const lift = (id: string) => {\n    const v = valuesFor(id);\n    v.z.set(10);\n    if (reduceMotion) v.lift.jump(1);\n    else animate(v.lift, 1, LIFT);\n  };\n\n  // Sets the card down from wherever it is, keeping the release velocity.\n  const settle = (id: string, velocity = { x: 0, y: 0 }) => {\n    const v = valuesFor(id);\n    const done = () => {\n      if (latest.current.held?.id !== id && session.current?.id !== id) {\n        v.z.set(0);\n      }\n    };\n    if (reduceMotion) {\n      [v.x, v.y, v.rotate, v.lift].forEach((mv) => mv.jump(0));\n      done();\n      return;\n    }\n    animate(v.x, 0, { ...HOME, velocity: velocity.x });\n    animate(v.y, 0, { ...HOME, velocity: velocity.y }).then(done);\n    animate(v.rotate, 0, HOME);\n    animate(v.lift, 0, LIFT);\n  };\n\n  // Keeps the dragged card under the pointer, inside the board, and moves\n  // its slot to wherever its centre now sits.\n  const follow = () => {\n    const s = session.current;\n    const board = boardRef.current;\n    const slot = s && slots.current.get(s.id);\n    if (!s?.started || !board || !slot) return;\n    const box = board.getBoundingClientRect();\n    // Offsets ignore transforms, so this is the slot's resting position even\n    // while its neighbours are mid-animation.\n    const homeLeft = box.left + slot.offsetLeft;\n    const homeTop = box.top + slot.offsetTop;\n    const w = slot.offsetWidth;\n    const h = slot.offsetHeight;\n    // 3px in from the edge leaves room for the lifted scale (1.5% of a\n    // ~180px card per side), so the card never pokes past the board and\n    // widens a narrow page.\n    const left = clamp(s.lastX - s.grabX, box.left + 3, box.right - w - 3);\n    const top = clamp(s.lastY - s.grabY, box.top + 3, box.bottom - h - 3);\n    const v = valuesFor(s.id);\n    v.x.jump(left - homeLeft);\n    v.y.jump(top - homeTop);\n\n    const { columns: current } = latest.current;\n    const centreX = left + w / 2;\n    const centreY = top + h / 2;\n    let toCol = 0;\n    let best = Infinity;\n    lists.current.forEach((list, i) => {\n      if (!list) return;\n      const r = list.getBoundingClientRect();\n      const d = Math.abs(centreX - (r.left + r.width / 2));\n      if (d < best) [best, toCol] = [d, i];\n    });\n    const list = lists.current[toCol];\n    if (!list) return;\n    const others = current[toCol].cards.filter((c) => c.id !== s.id).length;\n    // Rounding switches slots once the card is halfway into the next one.\n    const toIndex = clamp(\n      Math.round(\n        (centreY - list.getBoundingClientRect().top - h / 2) / (h + GAP),\n      ),\n      0,\n      others,\n    );\n    const from = locate(current, s.id);\n    if (from.col === toCol && from.index === toIndex) return;\n    latest.current.onChange(moveCard(current, s.id, toCol, toIndex));\n  };\n\n  // After the slot moves, re-pin the card to the pointer before paint.\n  useLayoutEffect(() => {\n    if (session.current?.started) follow();\n    // A released card glides home from exactly where it was let go, even\n    // when a cancel has just moved its slot back to where it started.\n    const r = release.current;\n    const board = boardRef.current;\n    const slot = r && slots.current.get(r.id);\n    if (r && board && slot) {\n      release.current = null;\n      const box = board.getBoundingClientRect();\n      const v = valuesFor(r.id);\n      v.x.jump(r.left - (box.left + slot.offsetLeft));\n      v.y.jump(r.top - (box.top + slot.offsetTop));\n      settle(r.id, r.velocity);\n    }\n    // Focus rides along when a card moves to another list and remounts.\n    if (held) {\n      const button = buttons.current.get(held.id);\n      if (button && document.activeElement !== button) {\n        button.focus({ preventScroll: true });\n      }\n    }\n  });\n\n  useEffect(() => () => session.current?.stop(), []);\n\n  const endDrag = (cancelled: boolean) => {\n    const s = session.current;\n    if (!s) return;\n    s.stop();\n    session.current = null;\n    if (!s.started) return;\n    const { columns: current, held: h } = latest.current;\n    const slot = slots.current.get(s.id);\n    const board = boardRef.current;\n    if (slot && board) {\n      const box = board.getBoundingClientRect();\n      const v = valuesFor(s.id);\n      release.current = {\n        id: s.id,\n        left: box.left + slot.offsetLeft + v.x.get(),\n        top: box.top + slot.offsetTop + v.y.get(),\n        velocity: { x: pointerX.getVelocity(), y: pointerY.getVelocity() },\n      };\n    }\n    if (cancelled && h) latest.current.onChange(h.before);\n    setHeld(null);\n    const list = cancelled && h ? h.before : current;\n    setAnnouncement(\n      `${cancelled ? \"Cancelled. Returned\" : \"Dropped\"} ${title(s.id, list)} to ${where(s.id, list)}.`,\n    );\n  };\n\n  const onPointerDown = (id: string, event: React.PointerEvent) => {\n    if (event.button !== 0 || session.current) return;\n    if (held) drop();\n    const onMove = (e: PointerEvent) => {\n      const s = session.current;\n      // Ignores a second finger, so switching fingers can't yank the card.\n      if (!s || e.pointerId !== s.pointerId) return;\n      s.lastX = e.clientX;\n      s.lastY = e.clientY;\n      if (!s.started) {\n        if (Math.hypot(e.clientX - s.startX, e.clientY - s.startY) < DRAG_SLOP)\n          return;\n        const slot = slots.current.get(id);\n        const board = boardRef.current;\n        if (!slot || !board) return;\n        const v = valuesFor(id);\n        // Grabbing a card that is still settling picks it up from where it\n        // visibly is, not from its slot.\n        v.x.stop();\n        v.y.stop();\n        const box = board.getBoundingClientRect();\n        s.grabX = s.startX - (box.left + slot.offsetLeft + v.x.get());\n        s.grabY = s.startY - (box.top + slot.offsetTop + v.y.get());\n        s.started = true;\n        pointerX.jump(e.clientX);\n        pointerY.jump(e.clientY);\n        if (!reduceMotion) {\n          const unsubscribe = tilt.on(\"change\", (r) => v.rotate.set(r));\n          const stop = s.stop;\n          s.stop = () => {\n            stop();\n            unsubscribe();\n          };\n        }\n        setHeld({ id, mode: \"pointer\", before: latest.current.columns });\n        lift(id);\n        setAnnouncement(`Picked up ${title(id)}.`);\n      }\n      pointerX.set(e.clientX);\n      pointerY.set(e.clientY);\n      follow();\n    };\n    const onUp = (e: PointerEvent) => {\n      if (e.pointerId === session.current?.pointerId) endDrag(false);\n    };\n    const onCancel = (e: PointerEvent) => {\n      if (e.pointerId === session.current?.pointerId) endDrag(true);\n    };\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\" && session.current?.started) {\n        e.preventDefault();\n        endDrag(true);\n      }\n    };\n    window.addEventListener(\"pointermove\", onMove);\n    window.addEventListener(\"pointerup\", onUp);\n    window.addEventListener(\"pointercancel\", onCancel);\n    window.addEventListener(\"keydown\", onKey);\n    session.current = {\n      id,\n      pointerId: event.pointerId,\n      startX: event.clientX,\n      startY: event.clientY,\n      grabX: 0,\n      grabY: 0,\n      lastX: event.clientX,\n      lastY: event.clientY,\n      started: false,\n      stop: () => {\n        window.removeEventListener(\"pointermove\", onMove);\n        window.removeEventListener(\"pointerup\", onUp);\n        window.removeEventListener(\"pointercancel\", onCancel);\n        window.removeEventListener(\"keydown\", onKey);\n      },\n    };\n  };\n\n  const pickUp = (id: string) => {\n    setHeld({ id, mode: \"keyboard\", before: columns });\n    lift(id);\n    setAnnouncement(`Picked up ${title(id)}, ${where(id)}.`);\n  };\n\n  const drop = () => {\n    const h = latest.current.held;\n    if (!h) return;\n    setHeld(null);\n    settle(h.id);\n    setAnnouncement(`Dropped ${title(h.id)} in ${where(h.id)}.`);\n  };\n\n  const cancel = () => {\n    if (!held) return;\n    onChange(held.before);\n    setHeld(null);\n    settle(held.id);\n    setAnnouncement(\n      `Cancelled. ${title(held.id)} returned to ${where(held.id, held.before)}.`,\n    );\n  };\n\n  const onKeyDown = (id: string, event: React.KeyboardEvent) => {\n    if (session.current?.started) return;\n    const { col, index } = locate(columns, id);\n    const isHeld = held?.id === id;\n    // Moves focus to the nearest card in the next column that has any.\n    const focusAcross = (step: number) => {\n      for (let c = col + step; c >= 0 && c < columns.length; c += step) {\n        const cards = columns[c].cards;\n        if (!cards.length) continue;\n        buttons.current.get(cards[Math.min(index, cards.length - 1)].id)?.focus();\n        return;\n      }\n    };\n    const focusWithin = (step: number) => {\n      const target = columns[col].cards[index + step];\n      if (target) buttons.current.get(target.id)?.focus();\n    };\n    const move = (toCol: number, toIndex: number) => {\n      if (toCol < 0 || toCol >= columns.length) return;\n      const others = columns[toCol].cards.filter((c) => c.id !== id).length;\n      const target = clamp(toIndex, 0, others);\n      if (toCol === col && target === index) return;\n      const next = moveCard(columns, id, toCol, target);\n      onChange(next);\n      setAnnouncement(`Moved to ${where(id, next)}.`);\n    };\n    const keys: Record<string, (() => void) | undefined> = {\n      \" \": () => (isHeld ? drop() : pickUp(id)),\n      Enter: () => (isHeld ? drop() : pickUp(id)),\n      Escape: isHeld ? cancel : undefined,\n      ArrowUp: () => (isHeld ? move(col, index - 1) : focusWithin(-1)),\n      ArrowDown: () => (isHeld ? move(col, index + 1) : focusWithin(1)),\n      ArrowLeft: () => (isHeld ? move(col - 1, index) : focusAcross(-1)),\n      ArrowRight: () => (isHeld ? move(col + 1, index) : focusAcross(1)),\n    };\n    const run = keys[event.key];\n    if (!run) return;\n    event.preventDefault();\n    run();\n  };\n\n  // Tabbing or clicking away sets a keyboard-held card down where it is.\n  // Checked a frame later, because a move between columns remounts the card\n  // and blurs it until the layout effect refocuses it.\n  const blurFrame = useRef(0);\n  useEffect(() => () => cancelAnimationFrame(blurFrame.current), []);\n  const onBlur = (id: string) => {\n    cancelAnimationFrame(blurFrame.current);\n    blurFrame.current = requestAnimationFrame(() => {\n      const h = latest.current.held;\n      if (h?.id !== id || h.mode !== \"keyboard\") return;\n      if (document.activeElement === buttons.current.get(id)) return;\n      drop();\n    });\n  };\n\n  const pointerDragging = held?.mode === \"pointer\";\n  const tabStop = columns.some((c) => c.cards.some((card) => card.id === focusId))\n    ? focusId\n    : columns.flatMap((c) => c.cards)[0]?.id;\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <LayoutGroup id={group}>\n        <div\n          ref={boardRef}\n          role=\"group\"\n          aria-label={label}\n          className={cn(\n            \"relative grid h-[380px] w-[600px] max-w-full grid-cols-3 gap-3\",\n            pointerDragging && \"cursor-grabbing select-none [&_*]:cursor-grabbing\",\n            className,\n          )}\n        >\n          {columns.map((column, c) => (\n            <div\n              key={column.id}\n              // Concentric with the cards: 18 = 10 radius + 8 padding.\n              className=\"flex min-w-0 flex-col rounded-[18px] bg-muted p-2\"\n            >\n              <div\n                aria-hidden\n                className=\"flex h-9 shrink-0 items-center justify-between px-2 text-sm font-medium text-muted-foreground\"\n              >\n                <span>{column.title}</span>\n                <Count value={column.cards.length} />\n              </div>\n              <ul\n                ref={(node) => {\n                  lists.current[c] = node;\n                }}\n                aria-label={column.title}\n                className=\"flex flex-1 flex-col gap-2\"\n              >\n                {column.cards.map((card) => (\n                  <Card\n                    key={card.id}\n                    card={card}\n                    values={valuesFor(card.id)}\n                    held={held?.id === card.id ? held.mode : null}\n                    tabbable={card.id === tabStop}\n                    describedBy={instructions}\n                    slotRef={(node) => {\n                      if (node) slots.current.set(card.id, node);\n                      else slots.current.delete(card.id);\n                    }}\n                    buttonRef={(node) => {\n                      if (node) buttons.current.set(card.id, node);\n                      else buttons.current.delete(card.id);\n                    }}\n                    onPointerDown={(e) => onPointerDown(card.id, e)}\n                    onKeyDown={(e) => onKeyDown(card.id, e)}\n                    onFocus={() => setFocusId(card.id)}\n                    onBlur={() => onBlur(card.id)}\n                  />\n                ))}\n              </ul>\n            </div>\n          ))}\n          <p id={instructions} className=\"sr-only\">\n            Press Space to pick up. While holding, use the arrow keys to move\n            within or between columns, Space to drop, or Escape to cancel.\n          </p>\n          <p className=\"sr-only\" aria-live=\"assertive\" aria-atomic>\n            {announcement}\n          </p>\n        </div>\n      </LayoutGroup>\n    </MotionConfig>\n  );\n}\n\nfunction Card({\n  card,\n  values,\n  held,\n  tabbable,\n  describedBy,\n  slotRef,\n  buttonRef,\n  onPointerDown,\n  onKeyDown,\n  onFocus,\n  onBlur,\n}: {\n  card: KanbanCard;\n  values: CardValues;\n  held: Held[\"mode\"] | null;\n  tabbable: boolean;\n  describedBy: string;\n  slotRef: (node: HTMLLIElement | null) => void;\n  buttonRef: (node: HTMLButtonElement | null) => void;\n  onPointerDown: (e: React.PointerEvent) => void;\n  onKeyDown: (e: React.KeyboardEvent) => void;\n  onFocus: () => void;\n  onBlur: () => void;\n}) {\n  const scale = useTransform(values.lift, [0, 1], [1, LIFT_SCALE]);\n  // The pointer-dragged card is placed by hand every frame, so its slot must\n  // not also animate or the card would drift off the pointer. A card held\n  // from the keyboard keeps its layoutId, so it glides between columns.\n  const byPointer = held === \"pointer\";\n\n  return (\n    <motion.li\n      ref={slotRef}\n      layout={byPointer ? false : \"position\"}\n      layoutId={byPointer ? undefined : card.id}\n      transition={LAYOUT}\n      className={cn(\n        \"h-11 shrink-0 rounded-[10px]\",\n        // The drop placeholder: the slot shows through once the card leaves it.\n        held &&\n          \"bg-foreground/[0.03] outline-1 -outline-offset-1 outline-foreground/20 outline-dashed\",\n      )}\n    >\n      <motion.button\n        ref={buttonRef}\n        type=\"button\"\n        tabIndex={tabbable ? 0 : -1}\n        aria-describedby={describedBy}\n        aria-pressed={held ? true : undefined}\n        style={{\n          x: values.x,\n          y: values.y,\n          scale,\n          rotate: values.rotate,\n          zIndex: values.z,\n        }}\n        onPointerDown={onPointerDown}\n        onKeyDown={onKeyDown}\n        onFocus={onFocus}\n        onBlur={onBlur}\n        className={cn(\n          \"relative flex size-full cursor-grab touch-none items-center rounded-[10px] bg-background px-3 text-left text-sm text-foreground shadow-raised outline-hidden select-none\",\n          \"transition-[scale] duration-150 ease-out active:scale-[0.96] motion-reduce:transition-none\",\n          \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-1 focus-visible:outline-foreground\",\n          // Lifted already reads as pressed; don't shrink under the lift.\n          held && \"active:scale-100\",\n        )}\n      >\n        <motion.span\n          aria-hidden\n          style={{ opacity: values.lift, boxShadow: LIFTED_SHADOW }}\n          className=\"pointer-events-none absolute inset-0 rounded-[inherit]\"\n        />\n        <span className=\"relative truncate\">{card.title}</span>\n      </motion.button>\n    </motion.li>\n  );\n}\n\n// Rolls up when a column gains a card and down when it loses one.\nconst ROLL: Variants = {\n  enter: (dir: number) => ({ y: dir * 8, opacity: 0, filter: \"blur(2px)\" }),\n  center: {\n    y: 0,\n    opacity: 1,\n    filter: \"blur(0px)\",\n    transition: { duration: 0.2, ease: [0.23, 1, 0.32, 1] },\n  },\n  exit: (dir: number) => ({\n    y: dir * -8,\n    opacity: 0,\n    filter: \"blur(2px)\",\n    transition: { duration: 0.15, ease: [0.23, 1, 0.32, 1] },\n  }),\n};\n\nfunction Count({ value }: { value: number }) {\n  const [shown, setShown] = useState({ value, dir: 1 });\n  // Direction is decided during render, so the new number enters from the\n  // right side on the very render it appears.\n  if (shown.value !== value) {\n    setShown({ value, dir: value > shown.value ? 1 : -1 });\n  }\n  return (\n    <span className=\"relative inline-flex h-4 min-w-2 justify-end overflow-hidden text-xs tabular-nums\">\n      <AnimatePresence mode=\"popLayout\" initial={false} custom={shown.dir}>\n        <motion.span\n          key={value}\n          custom={shown.dir}\n          variants={ROLL}\n          initial=\"enter\"\n          animate=\"center\"\n          exit=\"exit\"\n          className=\"leading-4\"\n        >\n          {value}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\nconst INITIAL: KanbanColumn[] = [\n  {\n    id: \"todo\",\n    title: \"Todo\",\n    cards: [\n      { id: \"spec\", title: \"Draft spec\" },\n      { id: \"icons\", title: \"Icon set\" },\n      { id: \"copy\", title: \"Empty states\" },\n    ],\n  },\n  {\n    id: \"doing\",\n    title: \"Doing\",\n    cards: [\n      { id: \"login\", title: \"Login flow\" },\n      { id: \"review\", title: \"Review PR\" },\n    ],\n  },\n  {\n    id: \"done\",\n    title: \"Done\",\n    cards: [{ id: \"tokens\", title: \"Color tokens\" }],\n  },\n];\n\nexport default function KanbanBoardDemo() {\n  const [columns, setColumns] = useState(INITIAL);\n  return (\n    <KanbanBoard columns={columns} onChange={setColumns} label=\"Project board\" />\n  );\n}\n"},{"path":"hooks/use-reduced-motion.ts","type":"registry:hook","target":"hooks/use-reduced-motion.ts","content":"\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n// Motion's useReducedMotion reads the media query on the very first client\n// render, but the server can't know it, so every component that renders\n// differently under reduced motion broke hydration for those users. This\n// reports false during hydration, matching the server HTML, then the real\n// preference straight after, and follows it if it changes.\nconst query = \"(prefers-reduced-motion: reduce)\";\n\nfunction subscribe(onChange: () => void) {\n  const media = window.matchMedia(query);\n  media.addEventListener(\"change\", onChange);\n  return () => media.removeEventListener(\"change\", onChange);\n}\n\nexport function useReducedMotion() {\n  return useSyncExternalStore(\n    subscribe,\n    () => window.matchMedia(query).matches,\n    () => false,\n  );\n}\n"}],"cssVars":{"light":{"shadow-raised":"0 0 0 1px oklch(0 0 0 / 0.06), 0 1px 2px oklch(0 0 0 / 0.06), 0 6px 16px -6px oklch(0 0 0 / 0.12)"},"dark":{"shadow-raised":"0 0 0 1px oklch(1 0 0 / 0.08), 0 1px 2px oklch(0 0 0 / 0.4), 0 6px 16px -6px oklch(0 0 0 / 0.6)"},"theme":{"shadow-raised":"var(--shadow-raised)"}},"categories":["data"],"docs":"From ui lab: https://lab.xevrion.dev/lab/kanban-board"}