import { Contact, Download, Globe, ImagePlus, Mail, MessageSquare, Phone, Type, Wifi, X, } from "lucide-react"; import QRCodeStyling from "qr-code-styling"; import { useCallback, useRef } from "react"; import { CollapsibleSection } from "@/components/common/collapsible-section"; import { type ContentType, type CornerDotType, type CornerSquareType, type DotType, type DownloadFormat, encodeQrData, useQrStore, } from "@/stores/qr-store"; // ── Content type tab definitions ───────────────────────────────────── const CONTENT_TYPES: { id: ContentType; label: string; icon: React.ComponentType<{ className?: string }>; }[] = [ { id: "url", label: "URL", icon: Globe }, { id: "text", label: "Text", icon: Type }, { id: "wifi", label: "WiFi", icon: Wifi }, { id: "vcard", label: "vCard", icon: Contact }, { id: "email", label: "Email", icon: Mail }, { id: "phone", label: "Phone", icon: Phone }, { id: "sms", label: "SMS", icon: MessageSquare }, ]; // ── Style option definitions ───────────────────────────────────────── const DOT_TYPES: { value: DotType; label: string }[] = [ { value: "square", label: "Square" }, { value: "rounded", label: "Rounded" }, { value: "dots", label: "Dots" }, { value: "classy", label: "Classy" }, { value: "classy-rounded", label: "Classy Rnd" }, { value: "extra-rounded", label: "Extra Rnd" }, ]; const CORNER_SQUARE_TYPES: { value: CornerSquareType; label: string }[] = [ { value: "square", label: "Square" }, { value: "rounded", label: "Rounded" }, { value: "dot", label: "Dot" }, { value: "extra-rounded", label: "Extra Rnd" }, ]; const CORNER_DOT_TYPES: { value: CornerDotType; label: string }[] = [ { value: "square", label: "Square" }, { value: "rounded", label: "Rounded" }, { value: "dot", label: "Dot" }, ]; const DOWNLOAD_FORMATS: { value: DownloadFormat; label: string; desc: string }[] = [ { value: "png", label: "PNG", desc: "Best for digital" }, { value: "svg", label: "SVG", desc: "Best for print" }, { value: "jpeg", label: "JPEG", desc: "Smaller file" }, { value: "webp", label: "WebP", desc: "Modern format" }, ]; // ── Data entry forms per content type ──────────────────────────────── const INPUT_CLASS = "w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"; const TEXTAREA_CLASS = `${INPUT_CLASS} resize-none`; function UrlForm() { const { textData, setTextData } = useQrStore(); return (
setTextData(e.target.value)} placeholder="https://example.com" className={INPUT_CLASS} data-testid="qr-input-url" />
); } function TextForm() { const { textData, setTextData } = useQrStore(); return (