{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sticky-notes",
  "title": "Sticky Notes",
  "author": "VenusUI",
  "description": "A board of handwritten sticky notes you can drag around; the one you grab comes to the front.",
  "files": [
    {
      "path": "registry/default/ui/sticky-notes.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface StickyNote {\n  id: string\n  text: string\n  color?: \"yellow\" | \"pink\" | \"blue\" | \"green\"\n  /** Starting position, as a percentage of the board's width and height. */\n  x: number\n  y: number\n  /** Tilt in degrees. */\n  rotate?: number\n}\n\ninterface StickyNotesProps extends React.ComponentProps<\"div\"> {\n  notes: StickyNote[]\n}\n\nconst COLORS = {\n  yellow: \"bg-[#fff3a6] text-[#5b4a12]\",\n  pink: \"bg-[#ffd3e1] text-[#6b2240]\",\n  blue: \"bg-[#cfe6ff] text-[#1e3a5f]\",\n  green: \"bg-[#d4f5c9] text-[#24502a]\",\n}\nconst HANDWRITING = '\"Segoe Print\", \"Bradley Hand\", \"Marker Felt\", \"Chalkboard SE\", cursive'\nconst KEY_STEP = 2 // percent\n\n/**\n * A board of sticky notes. Drag a note to move it; the note you grab comes\n * to the front. Keyboard users can focus a note and move it with the arrow\n * keys (hold Shift for bigger steps).\n */\nfunction StickyNotes({ notes, className, ...props }: StickyNotesProps) {\n  const boardRef = React.useRef<HTMLDivElement>(null)\n  const [positions, setPositions] = React.useState(() => Object.fromEntries(notes.map((n) => [n.id, { x: n.x, y: n.y }])))\n  const [stack, setStack] = React.useState(() => notes.map((n) => n.id))\n  const [dragging, setDragging] = React.useState<string | null>(null)\n  const grab = React.useRef({ dx: 0, dy: 0 })\n\n  const bringToFront = (id: string) => setStack((s) => [...s.filter((x) => x !== id), id])\n\n  const moveTo = (id: string, x: number, y: number) =>\n    setPositions((p) => ({ ...p, [id]: { x: Math.min(82, Math.max(0, x)), y: Math.min(78, Math.max(0, y)) } }))\n\n  return (\n    <div\n      ref={boardRef}\n      data-slot=\"sticky-notes\"\n      className={cn(\n        \"@container relative aspect-[4/3] w-full max-w-2xl touch-none overflow-hidden rounded-2xl border bg-[radial-gradient(var(--border)_1px,transparent_1px)] bg-size-[18px_18px] bg-muted/30\",\n        className\n      )}\n      {...props}\n    >\n      {notes.map((note) => {\n        const position = positions[note.id]\n        const z = stack.indexOf(note.id)\n        const isDragging = dragging === note.id\n        return (\n          <div\n            key={note.id}\n            role=\"note\"\n            tabIndex={0}\n            aria-label={`${note.text}. Use the arrow keys to move this note.`}\n            onPointerDown={(event) => {\n              const board = boardRef.current?.getBoundingClientRect()\n              if (!board) return\n              event.currentTarget.setPointerCapture(event.pointerId)\n              bringToFront(note.id)\n              setDragging(note.id)\n              grab.current = {\n                dx: event.clientX - board.left - (position.x / 100) * board.width,\n                dy: event.clientY - board.top - (position.y / 100) * board.height,\n              }\n            }}\n            onPointerMove={(event) => {\n              if (!isDragging) return\n              const board = boardRef.current?.getBoundingClientRect()\n              if (!board) return\n              moveTo(\n                note.id,\n                ((event.clientX - board.left - grab.current.dx) / board.width) * 100,\n                ((event.clientY - board.top - grab.current.dy) / board.height) * 100\n              )\n            }}\n            onPointerUp={() => setDragging(null)}\n            onPointerCancel={() => setDragging(null)}\n            onFocus={() => bringToFront(note.id)}\n            onKeyDown={(event) => {\n              const step = event.shiftKey ? KEY_STEP * 4 : KEY_STEP\n              const moves: Record<string, [number, number]> = {\n                ArrowLeft: [-step, 0],\n                ArrowRight: [step, 0],\n                ArrowUp: [0, -step],\n                ArrowDown: [0, step],\n              }\n              const move = moves[event.key]\n              if (!move) return\n              event.preventDefault()\n              moveTo(note.id, position.x + move[0], position.y + move[1])\n            }}\n            className={cn(\n              \"absolute flex aspect-square w-[18%] min-w-28 cursor-grab flex-col p-[2.5%] pt-[4%] outline-none select-none\",\n              \"shadow-[0_1px_1px_rgb(0_0_0/0.08),0_10px_18px_-10px_rgb(0_0_0/0.45)] focus-visible:ring-3 focus-visible:ring-ring/50\",\n              \"transition-[box-shadow,scale] duration-200\",\n              isDragging && \"scale-105 cursor-grabbing shadow-[0_2px_4px_rgb(0_0_0/0.1),0_22px_30px_-12px_rgb(0_0_0/0.5)]\",\n              COLORS[note.color ?? \"yellow\"]\n            )}\n            style={{\n              left: `${position.x}%`,\n              top: `${position.y}%`,\n              zIndex: z + 1,\n              rotate: `${isDragging ? 0 : (note.rotate ?? 0)}deg`,\n            }}\n          >\n            {/* Tape */}\n            <span aria-hidden=\"true\" className=\"absolute -top-2.5 left-1/2 h-5 w-14 -translate-x-1/2 rotate-[-4deg] bg-white/55 shadow-sm backdrop-blur-[1px]\" />\n            <p className=\"text-[clamp(0.8rem,1.9cqw,1.05rem)] leading-snug\" style={{ fontFamily: HANDWRITING }}>\n              {note.text}\n            </p>\n          </div>\n        )\n      })}\n    </div>\n  )\n}\n\nexport { StickyNotes }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "data-display"
  ],
  "type": "registry:ui"
}