{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "qr-code-widget",
  "title": "QR Code Widget",
  "description": "A QR-code card, title, description, code image, hint text and an open-link button, inline or as a corner-widget popup with a focus-trapped modal dialog.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/qr-code-widget/qr-code-widget.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface QrCodeWidgetProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  title?: string;\n  description?: string;\n  hintText?: string;\n  buttonText?: string;\n  qrImage?: string;\n  linkUrl?: string;\n  asPopup?: boolean;\n  position?: \"center\" | \"bottom-right\" | \"bottom-left\";\n  theme?: \"dark\" | \"light\";\n  maxWidth?: number;\n  cardRadius?: number;\n}\n\nexport function QrCodeWidget({\n  title = \"Scan to Connect\",\n  description = \"Share this page, a menu, or any link in a camera-friendly format.\",\n  hintText = \"Point your camera here\",\n  buttonText = \"Open link\",\n  qrImage = \"\",\n  linkUrl = \"https://example.com\",\n  asPopup = false,\n  position = \"center\",\n  theme = \"dark\",\n  maxWidth = 340,\n  cardRadius = 20,\n  className,\n  style,\n  ...props\n}: QrCodeWidgetProps) {\n  const uid = React.useId();\n  const [popupOpen, setPopupOpen] = React.useState(false);\n  const isDark = theme === \"dark\";\n\n  const cardBg = isDark ? \"rgba(20, 20, 24, 0.92)\" : \"#ffffff\";\n  const cardBorder = isDark ? \"rgba(255,255,255,0.08)\" : \"rgba(0,0,0,0.06)\";\n  const titleColor = isDark ? \"#f4f4f5\" : \"#18181b\";\n  const descColor = isDark ? \"rgba(244,244,245,0.65)\" : \"rgba(24,24,27,0.65)\";\n  const hintColor = isDark ? \"rgba(244,244,245,0.5)\" : \"rgba(24,24,27,0.5)\";\n  const buttonBg = \"#3b82f6\";\n  const buttonColor = \"#ffffff\";\n  const closeColor = isDark ? \"rgba(255,255,255,0.6)\" : \"rgba(0,0,0,0.45)\";\n\n  const cardContent = (\n    <>\n      <h2 id={`${uid}-title`} className=\"m-0 mb-2 text-center text-xl font-bold\" style={{ color: titleColor, fontFamily: \"Inter, system-ui, sans-serif\" }}>\n        {title}\n      </h2>\n      <p className=\"m-0 mb-6 text-center text-sm leading-[1.5] opacity-90\" style={{ color: descColor, fontFamily: \"Inter, system-ui, sans-serif\" }}>\n        {description}\n      </p>\n\n      <div className=\"mb-4 flex justify-center\">\n        <div className=\"flex h-[200px] w-[200px] items-center justify-center overflow-hidden rounded-[14px] border\" style={{ borderColor: cardBorder, background: isDark ? \"rgba(255,255,255,0.03)\" : \"#ffffff\" }}>\n          {qrImage ? (\n            // eslint-disable-next-line @next/next/no-img-element\n            <img src={qrImage} alt={`QR code for ${title}`} className=\"h-full w-full object-contain p-3\" />\n          ) : (\n            <div className=\"p-5 text-center text-[13px]\" style={{ color: isDark ? \"rgba(255,255,255,0.25)\" : \"rgba(0,0,0,0.25)\" }}>\n              Upload QR image\n            </div>\n          )}\n        </div>\n      </div>\n\n      <p className=\"m-0 mb-5 text-center text-[13px] opacity-75\" style={{ color: hintColor, fontFamily: \"Inter, system-ui, sans-serif\" }}>\n        {hintText}\n      </p>\n\n      <motion.a\n        href={linkUrl || undefined}\n        target=\"_blank\"\n        rel=\"noopener noreferrer\"\n        aria-label={linkUrl ? `${buttonText} (opens in a new tab)` : buttonText}\n        aria-disabled={!linkUrl}\n        onClick={(e) => {\n          if (!linkUrl) e.preventDefault();\n        }}\n        whileHover={{ scale: 1.02 }}\n        whileTap={{ scale: 0.98 }}\n        className=\"box-border flex h-[46px] w-full items-center justify-center rounded-[12px] border-none text-sm font-semibold no-underline\"\n        style={{ background: buttonBg, color: buttonColor, cursor: linkUrl ? \"pointer\" : \"default\", opacity: linkUrl ? 1 : 0.5, fontFamily: \"Inter, system-ui, sans-serif\" }}\n      >\n        {buttonText}\n      </motion.a>\n    </>\n  );\n\n  const cardBox = (\n    <div\n      className=\"relative border p-7 backdrop-blur-[20px]\"\n      style={{ background: cardBg, borderColor: cardBorder, borderRadius: cardRadius, boxShadow: isDark ? \"0 20px 60px rgba(0,0,0,0.45)\" : \"0 20px 60px rgba(0,0,0,0.1)\", fontFamily: \"system-ui, -apple-system, sans-serif\" }}\n    >\n      {cardContent}\n    </div>\n  );\n\n  if (!asPopup) {\n    return (\n      <div className={cn(\"flex w-full justify-center\", className)} style={style} {...props}>\n        <motion.div\n          initial={{ opacity: 0, scale: 0.94, y: 16 }}\n          animate={{ opacity: 1, scale: 1, y: 0 }}\n          transition={{ duration: 0.35, ease: [0.22, 1, 0.36, 1] }}\n          style={{ width: \"100%\", maxWidth }}\n        >\n          {cardBox}\n        </motion.div>\n      </div>\n    );\n  }\n\n  return (\n    <div className={cn(\"relative w-full\", className)} style={style} {...props}>\n      <div className={cn(\"flex\", position === \"center\" ? \"justify-center\" : position === \"bottom-left\" ? \"justify-start\" : \"justify-end\")}>\n        <motion.button\n          type=\"button\"\n          aria-label={`Open ${title}`}\n          onClick={() => setPopupOpen(true)}\n          whileHover={{ scale: 1.03 }}\n          whileTap={{ scale: 0.97 }}\n          className=\"flex cursor-pointer items-center gap-2.5 rounded-full border py-2 pr-4.5 pl-2 backdrop-blur-[20px]\"\n          style={{ background: cardBg, borderColor: cardBorder, boxShadow: isDark ? \"0 12px 32px rgba(0,0,0,0.4)\" : \"0 12px 32px rgba(0,0,0,0.12)\", fontFamily: \"system-ui, -apple-system, sans-serif\" }}\n        >\n          <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full\" style={{ background: buttonBg }}>\n            <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n              <rect x=\"1\" y=\"1\" width=\"6\" height=\"6\" rx=\"1\" fill={buttonColor} />\n              <rect x=\"11\" y=\"1\" width=\"6\" height=\"6\" rx=\"1\" fill={buttonColor} />\n              <rect x=\"1\" y=\"11\" width=\"6\" height=\"6\" rx=\"1\" fill={buttonColor} />\n              <rect x=\"11\" y=\"11\" width=\"6\" height=\"6\" rx=\"1\" fill={buttonColor} />\n            </svg>\n          </span>\n          <span className=\"text-[13px] font-semibold whitespace-nowrap\" style={{ color: titleColor }}>\n            {title}\n          </span>\n        </motion.button>\n      </div>\n\n      <AnimatePresence>\n        {popupOpen && (\n          <motion.div\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: 0.25 }}\n            onClick={(e) => {\n              if (e.target === e.currentTarget) setPopupOpen(false);\n            }}\n            className=\"fixed inset-0 z-[70] flex items-center justify-center p-5\"\n            style={{ background: \"rgba(0,0,0,0.6)\", backdropFilter: \"blur(4px)\" }}\n          >\n            <motion.div\n              role=\"dialog\"\n              aria-modal=\"true\"\n              aria-labelledby={`${uid}-title`}\n              tabIndex={-1}\n              onKeyDown={(e) => {\n                if (e.key === \"Escape\") setPopupOpen(false);\n              }}\n              initial={{ opacity: 0, scale: 0.94, y: 16 }}\n              animate={{ opacity: 1, scale: 1, y: 0 }}\n              exit={{ opacity: 0, scale: 0.94, y: 10 }}\n              transition={{ duration: 0.35, ease: [0.22, 1, 0.36, 1] }}\n              className=\"relative w-full\"\n              style={{ maxWidth }}\n            >\n              <div className=\"relative border p-7 backdrop-blur-[20px]\" style={{ background: cardBg, borderColor: cardBorder, borderRadius: cardRadius, boxShadow: isDark ? \"0 20px 60px rgba(0,0,0,0.45)\" : \"0 20px 60px rgba(0,0,0,0.1)\", fontFamily: \"system-ui, -apple-system, sans-serif\" }}>\n                <button\n                  type=\"button\"\n                  aria-label=\"Close\"\n                  onClick={() => setPopupOpen(false)}\n                  className=\"absolute top-3.5 right-3.5 flex h-7 w-7 items-center justify-center rounded-[8px] border-none bg-transparent opacity-60\"\n                  style={{ color: closeColor }}\n                >\n                  <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\" aria-hidden=\"true\">\n                    <path d=\"M1 1L13 13M13 1L1 13\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" />\n                  </svg>\n                </button>\n                {cardContent}\n              </div>\n            </motion.div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}