{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "qr-code",
  "title": "Qr Code",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/qr-code/QRCode.tsx",
      "content": "import * as React from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport QRCodeSvg from 'react-native-qrcode-svg'\nimport { Text } from '@/components/ui/text'\nimport { renderTextChildren } from '@/lib/label-children'\nimport { cn } from '@/lib/utils'\n\n/** Smaller boxes put modules under ~1dp for dense payloads; larger ones exceed tablet layouts. */\nexport const QR_CODE_MIN_SIZE = 96\nexport const QR_CODE_MAX_SIZE = 512\nconst DEFAULT_SIZE = 192\n\nexport type QRCodeErrorCorrection = 'L' | 'M' | 'Q' | 'H'\n\nexport interface QRCodeProps extends Omit<ViewProps, 'children'> {\n  /** Payload to encode. Empty or over-capacity values render `fallback`. */\n  value: string\n  /** Outer box in dp, quiet zone included. Clamped to 96–512. */\n  size?: number\n  /** Error correction level; higher survives damage but needs more modules. */\n  ecl?: QRCodeErrorCorrection\n  /**\n   * Light margin drawn inside `size`, in symbol units (the code spans `size` of\n   * them, so the code shrinks as this grows). Defaults to `size * 4 / 21`: four\n   * modules of the smallest (21-module) symbol, so every symbol version gets\n   * at least the four-module quiet zone the QR spec requires. Pass 0 only when\n   * the code already sits on a light surround of its own.\n   */\n  quietZone?: number\n  /**\n   * Modules and quiet zone stay dark-on-light in every theme: many scanners\n   * cannot read inverted codes, so these are not theme tokens and do not flip\n   * in dark mode. Keep at least the default contrast when overriding.\n   */\n  color?: string\n  backgroundColor?: string\n  /** Called once, after commit, when the value cannot be encoded. */\n  onError?: (error: Error) => void\n  /** Rendered inside the box when encoding fails. */\n  fallback?: React.ReactNode\n  className?: string\n}\n\nconst clamp = (value: number | undefined, fallback: number, min: number, max: number) =>\n  value !== undefined && Number.isFinite(value) ? Math.min(max, Math.max(min, Math.round(value))) : fallback\n\nexport const QRCode = React.forwardRef<React.ComponentRef<typeof View>, QRCodeProps>(\n  (\n    {\n      value,\n      size,\n      ecl = 'M',\n      quietZone,\n      color = '#000000',\n      backgroundColor = '#FFFFFF',\n      onError,\n      fallback = <Text variant=\"muted\">QR code unavailable.</Text>,\n      accessibilityLabel = 'QR code',\n      className,\n      style,\n      ...props\n    },\n    ref,\n  ) => {\n    const box = clamp(size, DEFAULT_SIZE, QR_CODE_MIN_SIZE, QR_CODE_MAX_SIZE)\n    const margin = clamp(quietZone, Math.ceil((box * 4) / 21), 0, Math.floor(box / 2))\n    // The library encodes in useMemo([value, size, ecl]) and calls onError during its render.\n    // Record the error in a ref there; report it and switch to the fallback from an effect.\n    const key = `${ecl}:${box}:${value}`\n    const pending = React.useRef<Error | null>(null)\n    const [failedKey, setFailedKey] = React.useState<string | null>(null)\n    const onErrorRef = React.useRef(onError)\n    React.useEffect(() => {\n      onErrorRef.current = onError\n    })\n    React.useEffect(() => {\n      const error = pending.current\n      pending.current = null\n      if (!error) {\n        setFailedKey(null)\n        return\n      }\n      setFailedKey(key)\n      onErrorRef.current?.(error)\n    }, [key])\n    const record = React.useCallback((error: unknown) => {\n      pending.current = error instanceof Error ? error : new Error(String(error))\n    }, [])\n    const failed = failedKey === key\n\n    return (\n      <View\n        {...props}\n        ref={ref}\n        accessible={!failed}\n        accessibilityRole={failed ? undefined : 'image'}\n        accessibilityLabel={failed ? undefined : accessibilityLabel}\n        className={cn('items-center justify-center overflow-hidden', className)}\n        style={[{ width: box, height: box }, style]}\n      >\n        {failed ? (\n          renderTextChildren(fallback)\n        ) : (\n          <QRCodeSvg\n            value={value}\n            size={box}\n            ecl={ecl}\n            quietZone={margin}\n            color={color}\n            backgroundColor={backgroundColor}\n            onError={record}\n          />\n        )}\n      </View>\n    )\n  },\n)\nQRCode.displayName = 'QRCode'\n",
      "type": "registry:ui",
      "target": "~/components/ui/qr-code/QRCode.tsx"
    },
    {
      "path": "packages/registry-native/components/qr-code/index.ts",
      "content": "export * from './QRCode'\n",
      "type": "registry:ui",
      "target": "~/components/ui/qr-code/index.ts"
    }
  ],
  "dependencies": [
    "react-native-qrcode-svg",
    "react-native-svg"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json",
    "https://native.uipkge.dev/r/native/label-children.json"
  ],
  "description": "Scannable dark-on-light QR code with bounded size, spec quiet zone, and an encode-failure fallback.",
  "categories": [
    "data-display"
  ]
}