{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "carousel-coverflow",
  "title": "Coverflow carousel",
  "description": "Styled carousel: the Coverflow set. 5 decorative carousel variations (FlowCarousel, DeepCarousel, TiltCarousel, FanCarousel, StackCarousel) on the ai2 token system, powered by framer-motion, reduced-motion aware and sized sm to xl. Part of the free styled layer.",
  "dependencies": [
    "motion@^12.42.2",
    "lucide-react@^1.23.0"
  ],
  "registryDependencies": [
    "@ai2/tokens"
  ],
  "files": [
    {
      "path": "registry/ai2/styled/carousel-coverflow.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Coverflow carousel family: 5 self-contained 3D perspective sliders (NO embla,\n   NO radix). The active slide sits in front and stays flat; the neighbouring\n   slides are pushed back with rotateY + scale + translateZ. Each export is a\n   complete carousel: it holds the slide index internally, and the arrows + dots\n   change it. Deterministic (index-based, no Date.now or Math.random). The root\n   carries data-slot=\"styled-carousel\" and role=\"region\". Color comes ONLY from\n   semantic tokens; the active dot is primary, via alpha color-mix. Gated on\n   framer's useReducedMotion: under reduced motion there is no 3D transform and\n   the slide changes instantly. */\n\nexport type StyledSize = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nconst trackHeight: Record<StyledSize, string> = {\n  sm: \"h-40\",\n  md: \"h-56\",\n  lg: \"h-72\",\n  xl: \"h-96\",\n}\n\nconst focusRing =\n  \"outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50\"\n\nconst arrowBtn =\n  \"absolute top-1/2 z-30 inline-flex size-9 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-[color-mix(in_oklab,var(--color-background)_72%,transparent)] text-foreground shadow-sm transition-colors supports-[backdrop-filter]:backdrop-blur hover:bg-background [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none\"\n\n/* Token-surfaced, numbered placeholder panels - for prop-less rendering. */\nconst panelTones = [\"bg-surface-2\", \"bg-surface-3\", \"bg-muted\", \"bg-accent\"]\n\nfunction defaultSlides(count = 4): React.ReactNode[] {\n  return Array.from({ length: count }, (_, i) => (\n    <div\n      key={i}\n      className={cn(\n        \"flex h-full w-full items-center justify-center\",\n        panelTones[i % panelTones.length]\n      )}\n    >\n      <span className=\"text-4xl font-semibold tabular-nums text-foreground\">{i + 1}</span>\n    </div>\n  ))\n}\n\nfunction resolveSlides(slides?: React.ReactNode[]): React.ReactNode[] {\n  return slides && slides.length > 0 ? slides : defaultSlides()\n}\n\n/* Ortak index state: sonsuz sarma (wrap) ile prev/next ve dogrudan jump. */\nfunction useCarousel(count: number) {\n  const [index, setIndex] = React.useState(0)\n  const total = Math.max(count, 1)\n  const wrap = React.useCallback((i: number) => ((i % total) + total) % total, [total])\n  const go = React.useCallback((i: number) => setIndex(wrap(i)), [wrap])\n  const next = React.useCallback(() => setIndex((p) => wrap(p + 1)), [wrap])\n  const prev = React.useCallback(() => setIndex((p) => wrap(p - 1)), [wrap])\n  return { index: Math.min(index, total - 1), setIndex: go, next, prev }\n}\n\n/* Shared dot group: the active one widens and turns primary. */\nfunction CarouselDots({\n  count,\n  index,\n  onSelect,\n  className,\n}: {\n  count: number\n  index: number\n  onSelect: (i: number) => void\n  className?: string\n}) {\n  const reduce = useReducedMotion()\n  return (\n    <div\n      role=\"tablist\"\n      aria-label=\"Choose slide to display\"\n      className={cn(\"flex items-center justify-center\", className)}\n    >\n      {Array.from({ length: count }, (_, i) => {\n        const active = i === index\n        return (\n          <button\n            key={i}\n            type=\"button\"\n            role=\"tab\"\n            aria-selected={active}\n            aria-label={`Go to slide ${i + 1}`}\n            onClick={() => onSelect(i)}\n            className={cn(\n              \"relative inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-full\",\n              focusRing\n            )}\n          >\n            <motion.span\n              aria-hidden=\"true\"\n              layout={!reduce}\n              transition={reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 500, damping: 34 }}\n              className={cn(\n                \"block h-2 rounded-full transition-colors\",\n                active\n                  ? \"w-6 bg-primary\"\n                  : \"w-2 bg-[color-mix(in_oklab,var(--color-foreground)_25%,transparent)] hover:bg-[color-mix(in_oklab,var(--color-foreground)_45%,transparent)]\"\n              )}\n            />\n          </button>\n        )\n      })}\n    </div>\n  )\n}\n\ninterface CarouselProps {\n  className?: string\n  size?: StyledSize\n  slides?: React.ReactNode[]\n}\n\n/* The setting set that decides the 3D intensity. gap: the neighbouring slide's horizontal shift (a percentage of its own width), angle: the rotateY degrees, scaleStep: the shrink per step, minScale: the lower bound, z: the translateZ pull-back (px), perspective: the scene depth, visible: how many neighbours are visible, width: the slide width. */\ninterface CoverflowConfig {\n  gap: number\n  angle: number\n  scaleStep: number\n  minScale: number\n  z: number\n  perspective: string\n  visible: number\n  width: string\n}\n\nfunction Coverflow({\n  className,\n  size = \"md\",\n  slides,\n  config,\n}: CarouselProps & { config: CoverflowConfig }) {\n  const reduce = useReducedMotion()\n  const items = resolveSlides(slides)\n  const { index, setIndex, next, prev } = useCarousel(items.length)\n  return (\n    <div\n      data-slot=\"styled-carousel\"\n      role=\"region\"\n      aria-roledescription=\"carousel\"\n      aria-label=\"Gallery\"\n      className={cn(\"relative w-full\", className)}\n    >\n      <div\n        className={cn(\"relative w-full overflow-hidden rounded-xl\", trackHeight[size])}\n        style={reduce ? undefined : { perspective: config.perspective }}\n      >\n        <div className=\"relative h-full w-full [transform-style:preserve-3d]\">\n          {items.map((slide, i) => {\n            const offset = i - index\n            const abs = Math.abs(offset)\n            const active = offset === 0\n            const target = reduce\n              ? { x: \"-50%\", rotateY: 0, scale: 1, z: 0, opacity: active ? 1 : 0 }\n              : {\n                  x: `calc(-50% + ${offset * config.gap}%)`,\n                  rotateY: -offset * config.angle,\n                  scale: active ? 1 : Math.max(config.minScale, 1 - abs * config.scaleStep),\n                  z: active ? 0 : -abs * config.z,\n                  opacity: abs > config.visible ? 0 : 1,\n                }\n            return (\n              <motion.div\n                key={i}\n                role=\"group\"\n                aria-roledescription=\"slide\"\n                aria-label={`${i + 1} of ${items.length}`}\n                aria-hidden={!active}\n                className=\"absolute left-1/2 top-1/2 h-[86%] -translate-y-1/2 overflow-hidden rounded-xl border border-border shadow-sm [transform-style:preserve-3d] [backface-visibility:hidden]\"\n                style={{ width: config.width, zIndex: 100 - abs }}\n                initial={false}\n                animate={target}\n                transition={reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 260, damping: 30 }}\n              >\n                <button\n                  type=\"button\"\n                  tabIndex={active ? -1 : 0}\n                  aria-label={`Go to slide ${i + 1}`}\n                  onClick={() => setIndex(i)}\n                  className={cn(\"block h-full w-full\", focusRing)}\n                >\n                  {slide}\n                </button>\n              </motion.div>\n            )\n          })}\n        </div>\n        <button type=\"button\" aria-label=\"Previous slide\" onClick={prev} className={cn(arrowBtn, focusRing, \"left-3\")}>\n          <ChevronLeft />\n        </button>\n        <button type=\"button\" aria-label=\"Next slide\" onClick={next} className={cn(arrowBtn, focusRing, \"right-3\")}>\n          <ChevronRight />\n        </button>\n      </div>\n      <CarouselDots count={items.length} index={index} onSelect={setIndex} className=\"mt-3\" />\n    </div>\n  )\n}\n\n/* Flow: dengeli coverflow, orta yogunlukta rotateY + geri cekilme. */\nexport function FlowCarousel(props: CarouselProps) {\n  return (\n    <Coverflow\n      {...props}\n      config={{ gap: 54, angle: 35, scaleStep: 0.12, minScale: 0.7, z: 120, perspective: \"1000px\", visible: 2, width: \"60%\" }}\n    />\n  )\n}\n\n/* Deep: guclu perspektif, komsular derine cekilir ve daha cok kuculur. */\nexport function DeepCarousel(props: CarouselProps) {\n  return (\n    <Coverflow\n      {...props}\n      config={{ gap: 46, angle: 46, scaleStep: 0.16, minScale: 0.64, z: 230, perspective: \"900px\", visible: 2, width: \"60%\" }}\n    />\n  )\n}\n\n/* Tilt: hafif, ince egim; genis aralik, dusuk aci. */\nexport function TiltCarousel(props: CarouselProps) {\n  return (\n    <Coverflow\n      {...props}\n      config={{ gap: 62, angle: 20, scaleStep: 0.08, minScale: 0.78, z: 80, perspective: \"1200px\", visible: 2, width: \"58%\" }}\n    />\n  )\n}\n\n/* Fan: genis yelpaze, buyuk aci ile uc komsu birden gorunur. */\nexport function FanCarousel(props: CarouselProps) {\n  return (\n    <Coverflow\n      {...props}\n      config={{ gap: 40, angle: 54, scaleStep: 0.13, minScale: 0.66, z: 170, perspective: \"1100px\", visible: 3, width: \"56%\" }}\n    />\n  )\n}\n\n/* Stack: komsular merkezin arkasina istiflenir; az yatay, cok derinlik. */\nexport function StackCarousel(props: CarouselProps) {\n  return (\n    <Coverflow\n      {...props}\n      config={{ gap: 16, angle: 12, scaleStep: 0.09, minScale: 0.72, z: 210, perspective: \"1000px\", visible: 3, width: \"64%\" }}\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/carousel-coverflow.tsx"
    }
  ],
  "categories": [
    "styled",
    "carousel"
  ],
  "type": "registry:component"
}