{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dot-pager-indicator",
  "title": "Dot Pager Indicator",
  "description": "Dots that show where you are in a carousel or onboarding flow: the active dot stretches into a pill, a progress style fills the pill and moves on by itself like stories, and a window style shows five dots out of many and shrinks the edge ones. Clickable and keyboard friendly.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/dot-pager-indicator/dot-pager-indicator.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useReducedMotion } 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 DotPagerIndicatorProps {\n  count: number;\n  /** Zero-based index of the current page. */\n  value?: number;\n  defaultValue?: number;\n  onValueChange?: (index: number) => void;\n  /**\n   * pill: the active dot stretches into a pill.\n   * progress: the active pill fills over `duration` ms, then moves on by itself.\n   * window: for many pages, shows `visible` dots and shrinks the ones at the edges.\n   */\n  variant?: \"pill\" | \"progress\" | \"window\";\n  /** progress: time per page in ms. */\n  duration?: number;\n  /** progress: pause autoplay (e.g. while the pointer is over the carousel). */\n  paused?: boolean;\n  /** window: how many dots to show at once. */\n  visible?: number;\n  size?: \"sm\" | \"md\" | \"lg\";\n  /** Clicking a dot jumps to that page. Off: a read-only indicator. */\n  interactive?: boolean;\n  label?: string;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { on: \"#F5F4F1\", off: \"rgba(245,244,241,0.25)\", offHover: \"rgba(245,244,241,0.5)\", track: \"rgba(245,244,241,0.22)\", focus: \"rgba(245,244,241,0.85)\" },\n  light: { on: \"#0A0A0A\", off: \"rgba(10,10,10,0.2)\", offHover: \"rgba(10,10,10,0.45)\", track: \"rgba(10,10,10,0.18)\", focus: \"rgba(10,10,10,0.85)\" },\n};\nconst SIZES = { sm: { dot: 6, pill: 18, gap: 6 }, md: { dot: 8, pill: 24, gap: 8 }, lg: { dot: 10, pill: 30, gap: 10 } };\n\nexport function DotPagerIndicator({ count, value, defaultValue = 0, onValueChange, variant = \"pill\", duration = 4000, paused = false, visible = 5, size = \"md\", interactive = true, label = \"Slides\", theme = \"dark\", className }: DotPagerIndicatorProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n  const reduce = Boolean(useReducedMotion());\n  const [internal, setInternal] = React.useState(defaultValue);\n  const current = Math.min(count - 1, Math.max(0, value ?? internal));\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const spring = reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 480, damping: 36 };\n\n  const go = React.useCallback(\n    (i: number) => {\n      const n = ((i % count) + count) % count;\n      if (value === undefined) setInternal(n);\n      onValueChange?.(n);\n    },\n    [count, value, onValueChange],\n  );\n\n  // Progress: move on once the active pill has filled.\n  React.useEffect(() => {\n    if (variant !== \"progress\" || paused || reduce) return;\n    const id = setTimeout(() => go(current + 1), duration);\n    return () => clearTimeout(id);\n  }, [variant, paused, reduce, duration, current, go]);\n\n  const onKey = (e: React.KeyboardEvent) => {\n    const map: Record<string, number> = { ArrowRight: current + 1, ArrowLeft: current - 1, Home: 0, End: count - 1 };\n    if (!(e.key in map)) return;\n    e.preventDefault();\n    const n = Math.min(count - 1, Math.max(0, map[e.key]));\n    go(n);\n    refs.current[n]?.focus();\n  };\n\n  // Window: keep the active dot inside a band of `visible` dots, sliding the row as it moves.\n  const win = Math.min(visible, count);\n  const start = variant === \"window\" ? Math.min(Math.max(0, current - Math.floor(win / 2)), count - win) : 0;\n  const step = s.dot + s.gap;\n\n  const dots = Array.from({ length: count }, (_, i) => {\n    const on = i === current;\n    let scale = 1;\n    let opacity = 1;\n    if (variant === \"window\") {\n      const pos = i - start;\n      if (pos < 0 || pos >= win) {\n        scale = 0.3;\n        opacity = 0;\n      } else if ((pos === 0 && start > 0) || (pos === win - 1 && start + win < count)) {\n        scale = 0.55; // edge dots hint that there's more\n      }\n    }\n    const width = variant === \"window\" ? s.dot : on ? s.pill : s.dot;\n    const Tag = interactive ? motion.button : motion.span;\n    return (\n      <Tag\n        key={i}\n        ref={(el: HTMLButtonElement | null) => {\n          refs.current[i] = el;\n        }}\n        {...(interactive ? { type: \"button\" as const, onClick: () => go(i), onKeyDown: onKey, tabIndex: on ? 0 : -1, \"aria-label\": `Go to slide ${i + 1}`, \"aria-current\": on ? (\"step\" as const) : undefined } : { \"aria-hidden\": true })}\n        className={cn(\"relative shrink-0 overflow-hidden rounded-full outline-none focus-visible:ring-2 focus-visible:ring-offset-2\", interactive && \"cursor-pointer\", interactive && !on && \"hover:bg-[var(--dp-hover)]\")}\n        style={{ height: s.dot, background: variant === \"progress\" && on ? p.track : on ? p.on : p.off, [\"--dp-hover\" as string]: p.offHover, [\"--tw-ring-color\" as string]: p.focus, [\"--tw-ring-offset-color\" as string]: \"transparent\", transition: \"background-color 0.2s ease\" }}\n        initial={false}\n        animate={{ width, scale, opacity }}\n        transition={spring}\n      >\n        {variant === \"progress\" && on && (\n          <motion.span\n            key={`fill-${current}`}\n            aria-hidden=\"true\"\n            className=\"absolute inset-y-0 left-0 block rounded-full\"\n            style={{ background: p.on }}\n            initial={{ width: reduce || paused ? \"100%\" : \"0%\" }}\n            animate={{ width: \"100%\" }}\n            transition={{ duration: reduce || paused ? 0 : duration / 1000, ease: \"linear\" }}\n          />\n        )}\n      </Tag>\n    );\n  });\n\n  return (\n    <div\n      role={interactive ? \"group\" : undefined}\n      aria-label={interactive ? label : undefined}\n      className={cn(\"relative flex items-center justify-center overflow-hidden\", className)}\n      style={{ height: s.dot + 8, width: variant === \"window\" ? win * step - s.gap + 8 : undefined }}\n    >\n      <motion.div className=\"flex items-center\" style={{ gap: s.gap }} initial={false} animate={{ x: variant === \"window\" ? -start * step + ((count - win) * step) / 2 : 0 }} transition={spring}>\n        {dots}\n      </motion.div>\n      {!interactive && (\n        <span className=\"sr-only\" aria-live=\"polite\">\n          {label} {current + 1} of {count}\n        </span>\n      )}\n    </div>\n  );\n}\n\nconst SLIDES = [\n  { title: \"Plan your week\", body: \"Drag tasks into days and see what fits.\" },\n  { title: \"Focus mode\", body: \"Hide everything but the task in front of you.\" },\n  { title: \"Share with your team\", body: \"Invite people and keep everyone in sync.\" },\n  { title: \"You're all set\", body: \"Start with a template or a blank board.\" },\n];\n\nexport function DotPagerIndicatorDemo({ theme = \"dark\" }: { theme?: \"dark\" | \"light\" }) {\n  const [step, setStep] = React.useState(0);\n  const [photo, setPhoto] = React.useState(3);\n  const t = theme === \"dark\" ? { bg: \"#0E0E0E\", border: \"rgba(255,255,255,0.1)\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.55)\", btn: \"#F5F4F1\", onBtn: \"#0A0A0A\", sub: \"rgba(255,255,255,0.05)\" } : { bg: \"#FFFFFF\", border: \"rgba(10,10,10,0.1)\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.55)\", btn: \"#0A0A0A\", onBtn: \"#FFFFFF\", sub: \"rgba(10,10,10,0.04)\" };\n  return (\n    <div className=\"flex flex-col items-center\" style={{ gap: 18, fontFamily: \"Inter, sans-serif\" }}>\n      <div className=\"flex w-[340px] max-w-full flex-col\" style={{ gap: 18, padding: 22, borderRadius: 18, background: t.bg, border: `1px solid ${t.border}` }}>\n        <div style={{ minHeight: 52 }}>\n          <p className=\"text-[15px] font-semibold\" style={{ color: t.text }}>\n            {SLIDES[step].title}\n          </p>\n          <p className=\"mt-1 text-[13px]\" style={{ color: t.muted }}>\n            {SLIDES[step].body}\n          </p>\n        </div>\n        <div className=\"flex items-center justify-between\">\n          <DotPagerIndicator theme={theme} count={SLIDES.length} value={step} onValueChange={setStep} label=\"Onboarding steps\" />\n          <button type=\"button\" onClick={() => setStep((s) => (s + 1) % SLIDES.length)} className=\"h-9 cursor-pointer rounded-xl text-[13px] font-semibold\" style={{ padding: \"0 16px\", background: t.btn, color: t.onBtn }}>\n            {step === SLIDES.length - 1 ? \"Start over\" : \"Next\"}\n          </button>\n        </div>\n      </div>\n      <div className=\"flex w-[340px] max-w-full items-center justify-between\" style={{ padding: \"12px 16px\", borderRadius: 14, background: t.sub, border: `1px solid ${t.border}` }}>\n        <span className=\"text-[12.5px]\" style={{ color: t.muted }}>\n          Stories\n        </span>\n        <DotPagerIndicator theme={theme} count={4} variant=\"progress\" duration={2600} label=\"Stories\" />\n      </div>\n      <div className=\"flex w-[340px] max-w-full items-center justify-between\" style={{ padding: \"12px 16px\", borderRadius: 14, background: t.sub, border: `1px solid ${t.border}` }}>\n        <span className=\"text-[12.5px] tabular-nums\" style={{ color: t.muted }}>\n          Photo {photo + 1} of 12\n        </span>\n        <DotPagerIndicator theme={theme} count={12} variant=\"window\" value={photo} onValueChange={setPhoto} label=\"Photos\" />\n      </div>\n    </div>\n  );\n}\n\nexport default DotPagerIndicator;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}