{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "product-list",
  "title": "Product List",
  "description": "An eCommerce product listing block with a filter sidebar (live search, Free/Premium tiers, categories) and a responsive photo grid with New and Sale badges.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/product-list/product-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion } 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 type ProductListTier = \"free\" | \"premium\";\nexport type ProductListBadge = \"new\" | \"sale\";\n\nexport interface ProductListItem {\n  title: string;\n  price: string;\n  compareAtPrice?: string;\n  category: string;\n  tier?: ProductListTier;\n  badge?: ProductListBadge;\n  image?: string;\n  url?: string;\n}\n\nexport interface ProductListProps {\n  products: ProductListItem[];\n  searchPlaceholder?: string;\n  priceLabel?: string;\n  categoriesLabel?: string;\n  allLabel?: string;\n  /** Color of the active filter, the radio dots and the \"New\" badge. */\n  accentColor?: string;\n  theme?: \"dark\" | \"light\";\n  onProductClick?: (product: ProductListItem) => void;\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", title: \"#FFFFFF\", muted: \"rgba(255,255,255,0.42)\", line: \"rgba(255,255,255,0.1)\", cardBg: \"rgba(255,255,255,0.03)\", cardBorder: \"rgba(255,255,255,0.12)\", cardHover: \"rgba(255,255,255,0.25)\", inputBg: \"rgba(255,255,255,0.04)\", fallback: \"#161616\", saleBg: \"#FFFFFF\", saleText: \"#111111\", focus: \"rgba(255,255,255,0.35)\", empty: \"rgba(255,255,255,0.7)\" },\n  light: { bg: \"#FFFFFF\", title: \"#111111\", muted: \"rgba(0,0,0,0.42)\", line: \"rgba(0,0,0,0.08)\", cardBg: \"rgba(0,0,0,0.02)\", cardBorder: \"rgba(0,0,0,0.1)\", cardHover: \"rgba(0,0,0,0.25)\", inputBg: \"rgba(0,0,0,0.03)\", fallback: \"#ECECEC\", saleBg: \"#111111\", saleText: \"#FFFFFF\", focus: \"rgba(0,0,0,0.28)\", empty: \"rgba(0,0,0,0.65)\" },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\n\nfunction FilterRow({ label, count, active, accent, p, radio, onClick }: { label: string; count: number; active: boolean; accent: string; p: Palette; radio?: boolean; onClick: () => void }) {\n  return (\n    <button\n      type=\"button\"\n      aria-pressed={active}\n      onClick={onClick}\n      className={cn(\"flex w-full cursor-pointer items-center gap-2 rounded-lg border-none bg-transparent text-left text-[14px] leading-[1.3] outline-none focus-visible:ring-2\", radio ? \"py-1.5\" : \"py-[7px]\")}\n      style={{ color: active ? accent : p.title, [\"--tw-ring-color\" as string]: p.focus }}\n    >\n      {radio && <span aria-hidden=\"true\" className=\"size-2.5 rounded-full\" style={{ border: `1.5px solid ${active ? accent : p.muted}`, background: active ? accent : \"transparent\" }} />}\n      <span className=\"flex-1\">{label}</span>\n      <span style={{ color: active ? accent : p.muted }}>{count}</span>\n    </button>\n  );\n}\n\n// \"$48.00\" as a schema.org Offer; undefined when the currency symbol isn't one we recognise.\nfunction toOffer(price: string | undefined) {\n  const currency = ({ $: \"USD\", \"€\": \"EUR\", \"£\": \"GBP\", \"₺\": \"TRY\", \"¥\": \"JPY\" } as Record<string, string>)[price?.trim()[0] ?? \"\"];\n  const amount = parseFloat(price?.replace(/[^0-9.]/g, \"\") ?? \"\");\n  return currency && !Number.isNaN(amount) ? { \"@type\": \"Offer\", price: amount.toFixed(2), priceCurrency: currency } : undefined;\n}\n\nexport function ProductList({\n  products,\n  searchPlaceholder = \"Search categories...\",\n  priceLabel = \"PRICE\",\n  categoriesLabel = \"CATEGORIES\",\n  allLabel = \"All Products\",\n  accentColor = \"#7CDE6A\",\n  theme = \"dark\",\n  onProductClick,\n  className,\n}: ProductListProps) {\n  const p = PALETTES[theme];\n  const [query, setQuery] = React.useState(\"\");\n  const [tier, setTier] = React.useState<\"all\" | ProductListTier>(\"all\");\n  const [category, setCategory] = React.useState(\"all\");\n\n  const hasTiers = products.some((item) => item.tier);\n  const categories = React.useMemo(() => {\n    const map = new Map<string, number>();\n    products.forEach((item) => map.set(item.category, (map.get(item.category) ?? 0) + 1));\n    return Array.from(map.entries());\n  }, [products]);\n\n  const freeCount = products.filter((item) => item.tier === \"free\").length;\n  const premiumCount = products.filter((item) => item.tier === \"premium\").length;\n\n  const filtered = React.useMemo(() => {\n    const q = query.trim().toLowerCase();\n    return products.filter((item) => {\n      const matchQuery = !q || item.title.toLowerCase().includes(q) || item.category.toLowerCase().includes(q);\n      const matchTier = tier === \"all\" || item.tier === tier;\n      const matchCategory = category === \"all\" || item.category === category;\n      return matchQuery && matchTier && matchCategory;\n    });\n  }, [products, query, tier, category]);\n\n  const clearFilters = () => {\n    setQuery(\"\");\n    setTier(\"all\");\n    setCategory(\"all\");\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.focus };\n\n  // schema.org ItemList of Products (JSON-LD) for search engines.\n  const jsonLd = JSON.stringify({\n    \"@context\": \"https://schema.org\",\n    \"@type\": \"ItemList\",\n    itemListElement: products.map((item, i) => ({\n      \"@type\": \"ListItem\",\n      position: i + 1,\n      item: {\n        \"@type\": \"Product\",\n        name: item.title,\n        category: item.category,\n        ...(item.image ? { image: item.image } : {}),\n        ...(item.url ? { url: item.url } : {}),\n        ...(toOffer(item.price) ? { offers: toOffer(item.price) } : {}),\n      },\n    })),\n  }).replace(/</g, \"\\\\u003c\");\n\n  return (\n    <div className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.title, fontFamily: \"Inter, sans-serif\" }}>\n      <script type=\"application/ld+json\" dangerouslySetInnerHTML={{ __html: jsonLd }} />\n      <div className=\"grid grid-cols-1 gap-[18px] p-4 pb-12 @[900px]:grid-cols-[240px_1fr] @[900px]:p-5 @[900px]:pb-12\">\n        <aside aria-label=\"Product filters\" className=\"@[900px]:sticky @[900px]:top-5 @[900px]:self-start\">\n          <div className=\"rounded-2xl p-4\" style={{ border: `1px solid ${p.cardBorder}` }}>\n            <label className=\"mb-[18px] flex items-center gap-2 rounded-xl px-3 py-2.5 focus-within:ring-2\" style={{ background: p.inputBg, border: `1px solid ${p.cardBorder}`, ...ring }}>\n              <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n                <circle cx=\"11\" cy=\"11\" r=\"6.5\" stroke={p.muted} strokeWidth=\"1.7\" />\n                <path d=\"M16.5 16.5L21 21\" stroke={p.muted} strokeWidth=\"1.7\" strokeLinecap=\"round\" />\n              </svg>\n              <input\n                value={query}\n                onChange={(e) => setQuery(e.target.value)}\n                placeholder={searchPlaceholder}\n                aria-label=\"Search products\"\n                className=\"w-full border-none bg-transparent text-[13px] leading-[1.3] outline-none\"\n                style={{ color: p.title }}\n              />\n            </label>\n\n            {hasTiers && (\n              <>\n                <div className=\"mb-2.5 text-[11px] leading-[1.2] font-medium tracking-[0.12em]\" style={{ color: p.muted }}>{priceLabel}</div>\n                <FilterRow radio label=\"Free\" count={freeCount} active={tier === \"free\"} accent={accentColor} p={p} onClick={() => setTier(tier === \"free\" ? \"all\" : \"free\")} />\n                <FilterRow radio label=\"Premium\" count={premiumCount} active={tier === \"premium\"} accent={accentColor} p={p} onClick={() => setTier(tier === \"premium\" ? \"all\" : \"premium\")} />\n                <div className=\"my-4 h-px\" style={{ background: p.line }} />\n              </>\n            )}\n\n            <div className=\"mb-2.5 text-[11px] leading-[1.2] font-medium tracking-[0.12em]\" style={{ color: p.muted }}>{categoriesLabel}</div>\n            <FilterRow label={allLabel} count={products.length} active={category === \"all\"} accent={accentColor} p={p} onClick={() => setCategory(\"all\")} />\n            {categories.map(([name, count]) => (\n              <FilterRow key={name} label={name} count={count} active={category === name} accent={accentColor} p={p} onClick={() => setCategory(category === name ? \"all\" : name)} />\n            ))}\n          </div>\n        </aside>\n\n        {filtered.length > 0 ? (\n          <div role=\"list\" aria-label=\"Product results\" className=\"grid grid-cols-1 content-start gap-3.5 @[560px]:grid-cols-2 @[900px]:grid-cols-3\">\n            {filtered.map((item, index) => (\n              <motion.a\n                key={item.title}\n                role=\"listitem\"\n                href={item.url}\n                aria-label={`${item.title}, ${item.price}`}\n                onClick={onProductClick ? () => onProductClick(item) : undefined}\n                initial={{ opacity: 0, y: 10 }}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ duration: 0.3, delay: Math.min(index, 8) * 0.03 }}\n                className=\"group block overflow-hidden rounded-2xl text-inherit no-underline outline-none transition-colors duration-200 hover:[border-color:var(--pl-hover)] focus-visible:ring-2\"\n                style={{ background: p.cardBg, border: `1px solid ${p.cardBorder}`, [\"--pl-hover\" as string]: p.cardHover, ...ring }}\n              >\n                <article>\n                  <div className=\"relative h-[170px] overflow-hidden\" style={{ background: p.fallback }}>\n                    {item.image && (\n                      // eslint-disable-next-line @next/next/no-img-element\n                      <img src={item.image} alt={item.title} loading=\"lazy\" className=\"block size-full object-cover transition-transform duration-500 ease-out group-hover:scale-[1.04]\" />\n                    )}\n                    {item.badge && (\n                      <span\n                        className=\"absolute top-2.5 left-2.5 rounded-full px-[9px] py-1 text-[11px] leading-[1.2] font-semibold\"\n                        style={item.badge === \"new\" ? { background: accentColor, color: \"#102010\" } : { background: p.saleBg, color: p.saleText }}\n                      >\n                        {item.badge === \"new\" ? \"New\" : \"Sale\"}\n                      </span>\n                    )}\n                  </div>\n                  <div className=\"px-3.5 pt-3 pb-3.5\">\n                    <h3 className=\"m-0 text-[15px] leading-[1.3] font-medium\" style={{ color: p.title }}>{item.title}</h3>\n                    <div className=\"mt-1.5 flex gap-2 text-[14px] leading-[1.3]\">\n                      <span style={{ color: p.title }}>{item.price}</span>\n                      {item.compareAtPrice && <span className=\"line-through\" style={{ color: p.muted }}>{item.compareAtPrice}</span>}\n                    </div>\n                  </div>\n                </article>\n              </motion.a>\n            ))}\n          </div>\n        ) : (\n          <div className=\"flex min-h-[220px] flex-col items-center justify-center gap-3 rounded-2xl p-8 text-center\" style={{ border: `1px dashed ${p.cardBorder}` }}>\n            <p className=\"m-0 text-[15px] font-medium\" style={{ color: p.title }}>No products match your filters</p>\n            <button\n              type=\"button\"\n              onClick={clearFilters}\n              className=\"cursor-pointer rounded-full bg-transparent px-4 py-1.5 text-[13px] outline-none focus-visible:ring-2\"\n              style={{ border: `1px solid ${p.cardBorder}`, color: p.empty, ...ring }}\n            >\n              Clear filters\n            </button>\n          </div>\n        )}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}