{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rubber-stamp",
  "title": "Rubber Stamp",
  "author": "VenusUI",
  "description": "A rubber stamp and a sheet of paper: click to stamp it, each impression a little crooked and worn.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "registry/default/ui/rubber-stamp.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Eraser } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface Impression {\n  id: number\n  x: number\n  y: number\n  tilt: number\n}\n\ninterface RubberStampProps extends React.ComponentProps<\"div\"> {\n  /** What the stamp says. */\n  text?: string\n  /** Ink colour. */\n  ink?: string\n  /** Content of the sheet being stamped. */\n  children?: React.ReactNode\n  onStamp?: (count: number) => void\n}\n\n/**\n * A rubber stamp and a sheet of paper. Click anywhere on the sheet to stamp\n * it; each impression lands a little crooked, with a worn-ink edge. The\n * \"Stamp\" button stamps the middle for keyboard users.\n */\nfunction RubberStamp({ text = \"APPROVED\", ink = \"#c2410c\", children, onStamp, className, ...props }: RubberStampProps) {\n  const [marks, setMarks] = React.useState<Impression[]>([])\n  const [pressed, setPressed] = React.useState(0)\n  const sheet = React.useRef<HTMLDivElement>(null)\n  const id = React.useId().replace(/[^a-zA-Z0-9]/g, \"\")\n\n  const stamp = (x: number, y: number) => {\n    const next = [...marks, { id: Date.now() + marks.length, x, y, tilt: Math.round((Math.random() * 16 - 8) * 10) / 10 }].slice(-12)\n    setMarks(next)\n    setPressed((value) => value + 1)\n    onStamp?.(next.length)\n  }\n\n  return (\n    <div data-slot=\"rubber-stamp\" className={cn(\"flex w-full max-w-lg flex-col gap-4\", className)} {...props}>\n      <svg aria-hidden=\"true\" className=\"absolute size-0\">\n        <filter id={`${id}-worn`}>\n          <feTurbulence type=\"fractalNoise\" baseFrequency=\"0.9\" numOctaves=\"2\" seed=\"4\" />\n          <feColorMatrix values=\"0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -1.6 1.25\" />\n          <feComposite in=\"SourceGraphic\" operator=\"in\" />\n        </filter>\n      </svg>\n      <div className=\"flex items-end gap-4\">\n        <div\n          ref={sheet}\n          onClick={(event) => {\n            const box = sheet.current?.getBoundingClientRect()\n            if (box) stamp(((event.clientX - box.left) / box.width) * 100, ((event.clientY - box.top) / box.height) * 100)\n          }}\n          className=\"relative aspect-[4/5] min-w-0 flex-1 cursor-crosshair overflow-hidden rounded-sm bg-[#fdfcf7] p-6 text-neutral-800 shadow-[0_14px_28px_-16px_rgb(0_0_0/0.5)] ring-1 ring-black/10\"\n        >\n          {children}\n          {marks.map((mark) => (\n            <span\n              key={mark.id}\n              aria-hidden=\"true\"\n              className=\"animate-rubber-stamp-press pointer-events-none absolute grid place-items-center rounded-md border-[3px] px-3 py-1 font-mono text-xl font-black tracking-[0.18em] whitespace-nowrap mix-blend-multiply motion-reduce:animate-none\"\n              style={{ left: `${mark.x}%`, top: `${mark.y}%`, color: ink, borderColor: ink, filter: `url(#${id}-worn)`, \"--tilt\": `${mark.tilt}deg`, rotate: `${mark.tilt}deg`, translate: \"-50% -50%\" } as React.CSSProperties}\n            >\n              {text}\n            </span>\n          ))}\n        </div>\n        {/* The stamp itself, which presses down each time. */}\n        <div aria-hidden=\"true\" key={pressed} className={cn(\"flex shrink-0 flex-col items-center\", pressed > 0 && \"animate-rubber-stamp-handle motion-reduce:animate-none\")}>\n          <span className=\"h-12 w-9 rounded-t-full rounded-b-md bg-linear-to-b from-amber-800 to-amber-950 shadow-inner\" />\n          <span className=\"h-3 w-5 bg-amber-950\" />\n          <span className=\"h-4 w-16 rounded-sm bg-linear-to-b from-neutral-300 to-neutral-500\" />\n          <span className=\"h-2 w-16 rounded-b-sm\" style={{ background: ink }} />\n        </div>\n      </div>\n      <div className=\"flex items-center gap-2\">\n        <button type=\"button\" onClick={() => stamp(50, 50)} className=\"rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground outline-none hover:bg-primary/90 focus-visible:ring-3 focus-visible:ring-ring/50\">\n          Stamp\n        </button>\n        <button type=\"button\" onClick={() => setMarks([])} disabled={!marks.length} className=\"inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm text-muted-foreground outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50\">\n          <Eraser aria-hidden=\"true\" className=\"size-4\" />\n          Clean sheet\n        </button>\n        <span role=\"status\" className=\"ml-auto text-xs text-muted-foreground\">\n          {marks.length ? `Stamped ${marks.length} ${marks.length === 1 ? \"time\" : \"times\"}` : \"Click the sheet to stamp it\"}\n        </span>\n      </div>\n    </div>\n  )\n}\n\nexport { RubberStamp }\n",
      "type": "registry:ui"
    }
  ],
  "cssVars": {
    "theme": {
      "animate-rubber-stamp-press": "rubber-stamp-press 0.25s cubic-bezier(.3,1.5,.6,1) both",
      "animate-rubber-stamp-handle": "rubber-stamp-handle 0.3s ease-out"
    }
  },
  "css": {
    "@keyframes rubber-stamp-press": {
      "from": {
        "scale": "1.6",
        "opacity": "0"
      },
      "to": {
        "scale": "1",
        "opacity": "0.9"
      }
    },
    "@keyframes rubber-stamp-handle": {
      "0%, 100%": {
        "transform": "translateY(0)"
      },
      "40%": {
        "transform": "translateY(14px)"
      }
    }
  },
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "animations"
  ],
  "type": "registry:ui"
}