{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sign-off-request-card",
  "title": "Sign-off Request Card",
  "description": "A formal approval in one card: the facts that matter, who signs in what order, a press-and-hold approve button, and a one-line way to send it back.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/sign-off-request-card/sign-off-request-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type SignOffStatus = \"signed\" | \"current\" | \"waiting\";\n\nexport interface SignOffApprover {\n  name: string;\n  role: string;\n  status: SignOffStatus;\n  /** Short time for someone who already signed, e.g. \"09:14\". */\n  time?: string;\n}\n\nexport interface SignOffFact {\n  label: string;\n  value: string;\n}\n\nexport interface SignOffRequestCardProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  /** A short id, e.g. \"CR-2041\". */\n  reference?: string;\n  requester?: string;\n  summary?: string;\n  facts?: SignOffFact[];\n  /** In signing order. The person using the card is the one marked current. */\n  approvers?: SignOffApprover[];\n  /** How long to hold the button, in milliseconds. Use 0 for a plain click. */\n  holdMs?: number;\n  onApprove?: () => void;\n  onRequestChanges?: (note: string) => void;\n}\n\ntype Stage = \"idle\" | \"changes\" | \"signed\" | \"returned\";\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst ACCENT = \"#5E6AD2\";\nconst GREEN = \"#27A644\";\nconst ORANGE = \"#FC7840\";\nconst RING =\n  \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2] focus-visible:ring-offset-0\";\n\nconst PALETTES = {\n  dark: {\n    card: \"#0F1011\",\n    inset: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    rail: \"rgba(255,255,255,0.1)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n    fill: \"rgba(94,106,210,0.42)\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    inset: \"#F7F8F8\",\n    border: \"rgba(8,9,10,0.1)\",\n    rail: \"rgba(8,9,10,0.12)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.05)\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n    fill: \"rgba(94,106,210,0.72)\",\n  },\n};\n\nconst DEFAULT_FACTS: SignOffFact[] = [\n  { label: \"Annual impact\", value: \"+$184,000\" },\n  { label: \"Starts\", value: \"1 February\" },\n  { label: \"Customers affected\", value: \"2,310\" },\n  { label: \"Risk\", value: \"Medium\" },\n];\n\nconst DEFAULT_APPROVERS: SignOffApprover[] = [\n  { name: \"Mira Holt\", role: \"Legal\", status: \"signed\", time: \"09:14\" },\n  { name: \"Jonas Reed\", role: \"Finance\", status: \"signed\", time: \"11:02\" },\n  { name: \"You\", role: \"Product\", status: \"current\" },\n  { name: \"Priya Nair\", role: \"Executive\", status: \"waiting\" },\n];\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle\n        cx={r}\n        cy={r}\n        r={r}\n        className=\"motion-safe:transition-[fill] motion-safe:duration-200\"\n        style={{ fill: color }}\n      />\n    </svg>\n  );\n}\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nexport function SignOffRequestCard({\n  theme = \"dark\",\n  title = \"Raise the Team plan to $14 a seat\",\n  reference = \"CR-2041\",\n  requester = \"Requested by Lena Ortiz, Pricing\",\n  summary = \"New signups move on 1 February. Existing customers keep their price for twelve months.\",\n  facts = DEFAULT_FACTS,\n  approvers = DEFAULT_APPROVERS,\n  holdMs = 900,\n  onApprove,\n  onRequestChanges,\n  className,\n  style,\n  ...rest\n}: SignOffRequestCardProps) {\n  const c = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const [stage, setStage] = React.useState<Stage>(\"idle\");\n  const [note, setNote] = React.useState(\"\");\n  const fillRef = React.useRef<HTMLSpanElement>(null);\n  const noteRef = React.useRef<HTMLInputElement>(null);\n  const raf = React.useRef(0);\n\n  const you = approvers.findIndex((a) => a.status === \"current\");\n  const next = approvers[you + 1];\n  const done = stage === \"signed\";\n  const rows = approvers.map((a, i) => {\n    if (!done) return a;\n    if (i === you) return { ...a, status: \"signed\" as const, time: \"Just now\" };\n    if (i === you + 1) return { ...a, status: \"current\" as const };\n    return a;\n  });\n  const signedCount = rows.filter((a) => a.status === \"signed\").length;\n\n  React.useEffect(() => () => cancelAnimationFrame(raf.current), []);\n  React.useEffect(() => {\n    if (stage === \"changes\") noteRef.current?.focus();\n  }, [stage]);\n\n  const paint = (p: number) => {\n    if (fillRef.current) fillRef.current.style.transform = `scaleX(${p})`;\n  };\n\n  const sign = () => {\n    cancelAnimationFrame(raf.current);\n    paint(0);\n    setStage(\"signed\");\n    onApprove?.();\n  };\n\n  const startHold = () => {\n    if (reduce || holdMs <= 0) {\n      sign();\n      return;\n    }\n    const began = performance.now();\n    const tick = (now: number) => {\n      const p = Math.min(1, (now - began) / holdMs);\n      paint(p);\n      if (p >= 1) sign();\n      else raf.current = requestAnimationFrame(tick);\n    };\n    raf.current = requestAnimationFrame(tick);\n  };\n\n  const stopHold = () => {\n    cancelAnimationFrame(raf.current);\n    paint(0);\n  };\n\n  const sendNote = (e: React.FormEvent) => {\n    e.preventDefault();\n    if (!note.trim()) return;\n    setStage(\"returned\");\n    onRequestChanges?.(note.trim());\n  };\n\n  const undo = () => {\n    setNote(\"\");\n    setStage(\"idle\");\n  };\n\n  const slot = (on: boolean) =>\n    `flex min-w-0 items-center gap-2 [grid-area:1/1] motion-safe:transition-opacity motion-safe:duration-200 ${on ? \"visible opacity-100\" : \"invisible opacity-0\"}`;\n  const secondary = `h-9 shrink-0 cursor-pointer rounded-full border-0 px-4 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] ${RING}`;\n\n  return (\n    <section\n      aria-label={title}\n      className={`@container w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <header className=\"p-5 pb-4 @xl:p-6 @xl:pb-5\">\n        <div\n          className=\"flex items-center justify-between gap-3 text-[12px] leading-[16px] tracking-[-0.005em] tabular-nums\"\n          style={{ color: c.faint }}\n        >\n          <span>{reference}</span>\n          <span>\n            {signedCount} of {approvers.length} signed\n          </span>\n        </div>\n        <h3 className=\"m-0 mt-2 text-[20px] leading-[26px] font-[590] tracking-[-0.018em]\">\n          {title}\n        </h3>\n        <p\n          className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n          style={{ color: c.sub }}\n        >\n          {requester}\n        </p>\n      </header>\n\n      <div\n        className=\"grid border-t @xl:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]\"\n        style={{ borderColor: c.border }}\n      >\n        <div className=\"p-5 @xl:p-6\">\n          <p\n            className=\"m-0 text-[13.5px] leading-[20px] tracking-[-0.011em]\"\n            style={{ color: c.soft }}\n          >\n            {summary}\n          </p>\n          <dl className=\"m-0 mt-4 grid grid-cols-2 gap-x-4 gap-y-3\">\n            {facts.map((f) => (\n              <div key={f.label} className=\"min-w-0\">\n                <dt\n                  className=\"truncate text-[12px] leading-[16px] tracking-[-0.005em]\"\n                  style={{ color: c.faint }}\n                >\n                  {f.label}\n                </dt>\n                <dd className=\"m-0 mt-0.5 truncate text-[14px] leading-[20px] font-[510] tracking-[-0.011em] tabular-nums\">\n                  {f.value}\n                </dd>\n              </div>\n            ))}\n          </dl>\n        </div>\n\n        <ol\n          aria-label=\"Sign-off order\"\n          className=\"m-0 list-none border-t p-5 @xl:border-t-0 @xl:border-l @xl:p-6\"\n          style={{ borderColor: c.border }}\n        >\n          {rows.map((a, i) => {\n            const last = i === rows.length - 1;\n            const dot =\n              a.status === \"signed\"\n                ? GREEN\n                : a.status === \"current\"\n                  ? ACCENT\n                  : c.rail;\n            return (\n              <li\n                key={a.name}\n                className=\"relative pb-4 last:pb-0\"\n                style={{ paddingLeft: 23 }}\n              >\n                {/* The dot and its line share one centred column, so they can't drift apart. */}\n                <span\n                  aria-hidden=\"true\"\n                  className=\"absolute flex flex-col items-center\"\n                  style={{\n                    top: 4,\n                    left: 0,\n                    width: 11,\n                    bottom: last ? undefined : -4,\n                  }}\n                >\n                  <Dot size={11} color={dot} />\n                  {!last && (\n                    <span\n                      className=\"my-1 w-px flex-1\"\n                      style={{ background: c.rail }}\n                    />\n                  )}\n                </span>\n                <div className=\"flex items-baseline justify-between gap-3\">\n                  <span\n                    className=\"truncate text-[13.5px] leading-[20px] font-[510] tracking-[-0.011em]\"\n                    style={{ color: a.status === \"waiting\" ? c.sub : c.text }}\n                  >\n                    {a.name}\n                  </span>\n                  <span\n                    className=\"shrink-0 text-[12px] leading-[16px] tracking-[-0.005em] tabular-nums\"\n                    style={{ color: a.status === \"current\" ? ACCENT : c.faint }}\n                  >\n                    {a.status === \"signed\"\n                      ? a.time\n                      : a.status === \"current\"\n                        ? \"Needed now\"\n                        : \"Waiting\"}\n                  </span>\n                </div>\n                <p\n                  className=\"m-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                  style={{ color: c.faint }}\n                >\n                  {a.role}\n                </p>\n              </li>\n            );\n          })}\n        </ol>\n      </div>\n\n      {/* Every state of the footer shares one cell, so the card keeps its height. */}\n      <footer\n        className=\"grid border-t px-5 py-3.5 @xl:px-6\"\n        style={{ borderColor: c.border }}\n      >\n        <div className={`${slot(stage === \"idle\")} justify-end`}>\n          <button\n            type=\"button\"\n            tabIndex={stage === \"idle\" ? 0 : -1}\n            onClick={() => setStage(\"changes\")}\n            className={`${secondary} flex-1 @xl:flex-none`}\n            style={{ background: c.chip, color: c.soft }}\n          >\n            Request changes\n          </button>\n          <button\n            type=\"button\"\n            tabIndex={stage === \"idle\" ? 0 : -1}\n            aria-label={holdMs > 0 ? \"Approve. Press and hold.\" : \"Approve\"}\n            onPointerDown={startHold}\n            onPointerUp={stopHold}\n            onPointerLeave={stopHold}\n            onPointerCancel={stopHold}\n            onContextMenu={(e) => e.preventDefault()}\n            onKeyDown={(e) => {\n              if ((e.key === \"Enter\" || e.key === \" \") && !e.repeat) {\n                e.preventDefault();\n                sign();\n              }\n            }}\n            className={`relative h-9 flex-1 cursor-pointer touch-manipulation overflow-hidden rounded-full border-0 px-4 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] select-none @xl:w-[148px] @xl:flex-none ${RING}`}\n            style={{ background: c.btn, color: c.btnText }}\n          >\n            <span\n              ref={fillRef}\n              aria-hidden=\"true\"\n              className=\"absolute inset-0 origin-left\"\n              style={{ background: c.fill, transform: \"scaleX(0)\" }}\n            />\n            <span className=\"relative\">\n              {holdMs > 0 ? \"Hold to approve\" : \"Approve\"}\n            </span>\n          </button>\n        </div>\n\n        <form onSubmit={sendNote} className={slot(stage === \"changes\")}>\n          <input\n            ref={noteRef}\n            value={note}\n            tabIndex={stage === \"changes\" ? 0 : -1}\n            onChange={(e) => setNote(e.target.value)}\n            onKeyDown={(e) => {\n              if (e.key === \"Escape\") setStage(\"idle\");\n            }}\n            aria-label=\"What needs to change?\"\n            placeholder=\"What needs to change?\"\n            className=\"h-9 min-w-0 flex-1 rounded-full border px-4 text-[16px] tracking-[-0.011em] outline-none focus:border-[#5E6AD2] @xl:text-[13px]\"\n            style={{\n              background: c.inset,\n              borderColor: c.border,\n              color: c.text,\n            }}\n          />\n          <button\n            type=\"submit\"\n            tabIndex={stage === \"changes\" ? 0 : -1}\n            disabled={!note.trim()}\n            className={`${secondary} disabled:cursor-default`}\n            style={{\n              background: note.trim() ? c.btn : c.chip,\n              color: note.trim() ? c.btnText : c.faint,\n            }}\n          >\n            Send\n          </button>\n        </form>\n\n        <div\n          aria-live=\"polite\"\n          className={`${slot(stage === \"signed\" || stage === \"returned\")} justify-between`}\n        >\n          <p className=\"m-0 flex min-w-0 items-center gap-2 text-[13px] leading-[20px] font-[510] tracking-[-0.011em]\">\n            <Dot size={8} color={done ? GREEN : ORANGE} />\n            <span className=\"truncate\">\n              {done\n                ? next\n                  ? `Signed. Waiting on ${next.name}.`\n                  : \"Signed by everyone.\"\n                : stage === \"returned\"\n                  ? `Sent back: ${note}`\n                  : \"\"}\n            </span>\n          </p>\n          <button\n            type=\"button\"\n            tabIndex={done || stage === \"returned\" ? 0 : -1}\n            onClick={undo}\n            className={secondary}\n            style={{ background: c.chip, color: c.soft }}\n          >\n            Undo\n          </button>\n        </div>\n      </footer>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}