{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"changelog-section","type":"registry:block","title":"Changelog Section","description":"A release timeline where each version expands in place to list its New, Improved and Fixed changes. The rail draws down as entries enter, and the newest release carries a lens dot and a Latest badge.","dependencies":["motion","lucide-react"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/changelog-section/changelog-section.tsx","type":"registry:component","content":"\"use client\";\n\nimport { useId, useRef, useState } from \"react\";\nimport {\n  AnimatePresence,\n  MotionConfig,\n  motion,\n  useInView,\n  useReducedMotion,\n} from \"motion/react\";\nimport { ArrowUpRight, ChevronDown } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\n/* ------------------------------------------------------------------ */\n/* types                                                               */\n/* ------------------------------------------------------------------ */\n\nexport type ChangelogChangeTag = \"new\" | \"improved\" | \"fixed\";\n\nexport type ChangelogChange = {\n  tag: ChangelogChangeTag;\n  /** One concrete line describing the change. */\n  text: string;\n};\n\nexport type ChangelogRelease = {\n  id: string;\n  version: string;\n  /** Display date, e.g. \"Oct 28, 2026\". */\n  date: string;\n  /** One-line title for the release. */\n  title: string;\n  changes: ChangelogChange[];\n};\n\nexport type ChangelogSectionProps = {\n  className?: string;\n  title?: string;\n  description?: string;\n  releases?: ChangelogRelease[];\n  /** Id of the release expanded on first render. Defaults to the newest one. */\n  defaultOpenId?: string;\n  feedHref?: string;\n  feedLabel?: string;\n};\n\n/* ------------------------------------------------------------------ */\n/* deterministic demo data                                             */\n/* ------------------------------------------------------------------ */\n\nconst DEFAULT_RELEASES: ChangelogRelease[] = [\n  {\n    id: \"v2-4-0\",\n    version: \"v2.4.0\",\n    date: \"Nov 10, 2026\",\n    title: \"Saved views, background exports, and a quieter sidebar\",\n    changes: [\n      {\n        tag: \"new\",\n        text: \"Saved views pin filters, sorting, and columns, then share the whole layout with a link.\",\n      },\n      {\n        tag: \"improved\",\n        text: \"CSV exports run in the background and land in your inbox when they are ready.\",\n      },\n      {\n        tag: \"improved\",\n        text: \"The sidebar remembers which sections you keep open, separately for each workspace.\",\n      },\n      {\n        tag: \"fixed\",\n        text: \"Date ranges no longer slip by a day for timezones west of UTC.\",\n      },\n    ],\n  },\n  {\n    id: \"v2-3-2\",\n    version: \"v2.3.2\",\n    date: \"Oct 27, 2026\",\n    title: \"Timezone fixes and a faster command menu\",\n    changes: [\n      {\n        tag: \"fixed\",\n        text: \"Scheduled reports now use the workspace timezone instead of the browser one.\",\n      },\n      {\n        tag: \"improved\",\n        text: \"The command menu opens in 40 ms and indexes the last 12 months by default.\",\n      },\n      {\n        tag: \"fixed\",\n        text: \"Session expiry no longer interrupts an export that is already running.\",\n      },\n    ],\n  },\n  {\n    id: \"v2-3-0\",\n    version: \"v2.3.0\",\n    date: \"Oct 13, 2026\",\n    title: \"Audit log, custom roles, and bulk actions\",\n    changes: [\n      {\n        tag: \"new\",\n        text: \"Audit log with 90-day retention, filterable by member and by resource.\",\n      },\n      {\n        tag: \"new\",\n        text: \"Custom roles let you grant read-only access to a single project.\",\n      },\n      {\n        tag: \"improved\",\n        text: \"Bulk actions now act on 500 rows at once, with a progress indicator.\",\n      },\n      {\n        tag: \"fixed\",\n        text: \"Long workspace names truncate instead of pushing the avatar off-screen.\",\n      },\n    ],\n  },\n  {\n    id: \"v2-2-0\",\n    version: \"v2.2.0\",\n    date: \"Sep 29, 2026\",\n    title: \"Search, keyboard-first\",\n    changes: [\n      {\n        tag: \"new\",\n        text: \"Search across projects, invoices, and people from one box.\",\n      },\n      {\n        tag: \"new\",\n        text: \"Press ? anywhere to see every shortcut in the product.\",\n      },\n      {\n        tag: \"improved\",\n        text: \"Focus returns to the button that opened a dialog when it closes.\",\n      },\n    ],\n  },\n];\n\n/* ------------------------------------------------------------------ */\n/* tag styles                                                          */\n/* ------------------------------------------------------------------ */\n\nconst TAG_META: Record<\n  ChangelogChangeTag,\n  { label: string; className: string }\n> = {\n  new: {\n    label: \"New\",\n    className: \"border-success/25 bg-success/10 text-foreground\",\n  },\n  improved: {\n    label: \"Improved\",\n    className: \"border-chart-2/30 bg-chart-2/10 text-foreground\",\n  },\n  fixed: {\n    label: \"Fixed\",\n    className: \"border-border bg-muted text-muted-foreground\",\n  },\n};\n\n/* ------------------------------------------------------------------ */\n/* one release                                                         */\n/* ------------------------------------------------------------------ */\n\ntype ReleaseItemProps = {\n  release: ChangelogRelease;\n  index: number;\n  total: number;\n  open: boolean;\n  reduce: boolean;\n  onToggle: () => void;\n};\n\nfunction ReleaseItem({\n  release,\n  index,\n  total,\n  open,\n  reduce,\n  onToggle,\n}: ReleaseItemProps) {\n  const itemRef = useRef<HTMLLIElement>(null);\n  const panelId = useId();\n  const inView = useInView(itemRef, {\n    once: true,\n    margin: \"-8% 0px -18% 0px\",\n  });\n  const reached = reduce || inView;\n  const isFirst = index === 0;\n  const isLast = index === total - 1;\n  const isOnly = total === 1;\n\n  return (\n    <motion.li\n      ref={itemRef}\n      initial={{ opacity: 0, y: reduce ? 0 : 10 }}\n      animate={{ opacity: reached ? 1 : 0, y: 0 }}\n      transition={{\n        duration: reduce ? 0 : 0.5,\n        ease: EASE,\n        delay: reduce ? 0 : Math.min(index, 3) * 0.05,\n      }}\n      className={cn(\"relative pl-7 sm:pl-8\", !isLast && \"pb-2\")}\n    >\n      {/* rail segment: base line plus a foreground line that draws in */}\n      {!isOnly ? (\n        <div\n          aria-hidden=\"true\"\n          className={cn(\n            \"pointer-events-none absolute left-[7.5px] w-px\",\n            isFirst ? \"top-[17px]\" : \"top-0\",\n            isLast ? \"h-[17px]\" : \"bottom-0\"\n          )}\n        >\n          <span className=\"absolute inset-0 bg-border\" />\n          <motion.span\n            className=\"absolute inset-0 origin-top bg-foreground/25\"\n            initial={false}\n            animate={{ scaleY: reached ? 1 : 0 }}\n            transition={{\n              duration: reduce ? 0 : 0.9,\n              ease: EASE,\n              delay: reduce ? 0 : 0.15,\n            }}\n          />\n        </div>\n      ) : null}\n\n      {/* the newest entry carries the lens; older entries are plain dots */}\n      <span\n        aria-hidden=\"true\"\n        className=\"absolute left-0 top-[9px] flex h-4 w-4 items-center justify-center\"\n      >\n        {isFirst ? (\n          <>\n            <span className=\"absolute inset-0 rounded-full border border-border bg-card\" />\n            <motion.span\n              className=\"absolute inset-[3px] rounded-full bg-foreground\"\n              initial={false}\n              animate={{ scale: reached ? 1 : 0, opacity: reached ? 1 : 0 }}\n              transition={{ duration: reduce ? 0 : 0.45, ease: EASE }}\n            />\n            <motion.span\n              className=\"absolute right-[4px] top-[4px] h-[3px] w-[3px] rounded-full bg-muted-foreground/50\"\n              initial={false}\n              animate={{ opacity: reached ? 0 : 1 }}\n              transition={{ duration: reduce ? 0 : 0.25 }}\n            />\n            <motion.span\n              className=\"absolute right-[4px] top-[4px] h-[3px] w-[3px] rounded-full bg-card\"\n              initial={false}\n              animate={{ opacity: reached ? 1 : 0 }}\n              transition={{ duration: reduce ? 0 : 0.25 }}\n            />\n          </>\n        ) : (\n          <motion.span\n            className=\"absolute inset-[5px] rounded-full bg-foreground/30\"\n            initial={false}\n            animate={{ scale: reached ? 1 : 0, opacity: reached ? 1 : 0 }}\n            transition={{ duration: reduce ? 0 : 0.35, ease: EASE }}\n          />\n        )}\n      </span>\n\n      <div>\n        <button\n          type=\"button\"\n          onClick={onToggle}\n          aria-expanded={open}\n          aria-controls={open ? panelId : undefined}\n          className={cn(\n            \"-mx-2 flex w-[calc(100%+1rem)] flex-col rounded-lg px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\",\n            open ? \"bg-muted/30\" : \"hover:bg-muted/40\"\n          )}\n        >\n          <span className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n            <span className=\"text-[15px] font-semibold tracking-tight tabular-nums\">\n              {release.version}\n            </span>\n            {isFirst ? (\n              <span className=\"inline-flex items-center gap-1 rounded-full border border-success/25 bg-success/10 px-1.5 py-0.5 text-[10px] font-medium leading-none text-foreground\">\n                <span\n                  aria-hidden=\"true\"\n                  className=\"h-1 w-1 rounded-full bg-success\"\n                />\n                Latest\n              </span>\n            ) : null}\n            <span className=\"text-[12px] tabular-nums text-muted-foreground\">\n              {release.date}\n            </span>\n            <ChevronDown\n              aria-hidden=\"true\"\n              className={cn(\n                \"ml-auto h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-300 motion-reduce:transition-none\",\n                open ? \"rotate-180\" : \"rotate-0\"\n              )}\n            />\n          </span>\n          <span className=\"mt-1 block text-[13.5px] font-medium leading-snug text-card-foreground/80\">\n            {release.title}\n          </span>\n        </button>\n\n        <AnimatePresence initial={false}>\n          {open ? (\n            <motion.div\n              key=\"panel\"\n              id={panelId}\n              role=\"region\"\n              aria-label={`${release.version} changes`}\n              initial={{ opacity: 0, y: reduce ? 0 : -4 }}\n              animate={{ opacity: 1, y: 0 }}\n              exit={{ opacity: 0, y: reduce ? 0 : -4 }}\n              transition={{ duration: reduce ? 0 : 0.24, ease: EASE }}\n            >\n              <ul className=\"mt-1 space-y-2.5 border-t border-border px-2 pb-2 pt-3\">\n                {release.changes.map((change, changeIndex) => {\n                  const meta = TAG_META[change.tag];\n                  return (\n                    <li\n                      key={`${release.id}-${changeIndex}`}\n                      className=\"flex items-start gap-2.5\"\n                    >\n                      <span\n                        className={cn(\n                          \"mt-px inline-flex min-w-[64px] shrink-0 items-center justify-center rounded border px-1.5 py-0.5 text-[10px] font-medium leading-none tracking-wide\",\n                          meta.className\n                        )}\n                      >\n                        {meta.label}\n                      </span>\n                      <span className=\"min-w-0 text-[13px] leading-relaxed text-muted-foreground\">\n                        {change.text}\n                      </span>\n                    </li>\n                  );\n                })}\n              </ul>\n            </motion.div>\n          ) : null}\n        </AnimatePresence>\n      </div>\n    </motion.li>\n  );\n}\n\n/* ------------------------------------------------------------------ */\n/* block                                                               */\n/* ------------------------------------------------------------------ */\n\nexport function ChangelogSection({\n  className,\n  title = \"Changelog\",\n  description = \"Product changes, written the week they ship. New builds land every other Tuesday.\",\n  releases = DEFAULT_RELEASES,\n  defaultOpenId,\n  feedHref = \"https://github.com/prequelui/prequelui/releases\",\n  feedLabel = \"All releases\",\n}: ChangelogSectionProps) {\n  const sectionRef = useRef<HTMLElement>(null);\n  const titleId = useId();\n  const inView = useInView(sectionRef, { once: true, margin: \"-10% 0px\" });\n  const reduce = Boolean(useReducedMotion());\n  const show = reduce || inView;\n  const [openId, setOpenId] = useState<string | null>(\n    defaultOpenId ?? releases[0]?.id ?? null\n  );\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <section\n        ref={sectionRef}\n        aria-labelledby={titleId}\n        className={cn(\n          \"rounded-xl border border-border bg-card p-5 text-card-foreground sm:p-7\",\n          className\n        )}\n      >\n        <motion.header\n          initial={{ opacity: 0, y: reduce ? 0 : 12 }}\n          animate={{ opacity: show ? 1 : 0, y: 0 }}\n          transition={{ duration: reduce ? 0 : 0.55, ease: EASE }}\n          className=\"flex flex-wrap items-start justify-between gap-3\"\n        >\n          <div className=\"min-w-0\">\n            <h2\n              id={titleId}\n              className=\"text-[20px] font-semibold tracking-tight sm:text-[22px]\"\n            >\n              {title}\n            </h2>\n            {description ? (\n              <p className=\"mt-1 max-w-md text-[13px] leading-relaxed text-muted-foreground\">\n                {description}\n              </p>\n            ) : null}\n          </div>\n\n          <a\n            href={feedHref}\n            target=\"_blank\"\n            rel=\"noreferrer\"\n            className=\"group inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-[12.5px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n          >\n            {feedLabel}\n            <ArrowUpRight\n              aria-hidden=\"true\"\n              className=\"h-3.5 w-3.5 transition-transform duration-300 group-hover:-translate-y-0.5 group-hover:translate-x-0.5 motion-reduce:transition-none motion-reduce:group-hover:translate-x-0 motion-reduce:group-hover:translate-y-0\"\n            />\n          </a>\n        </motion.header>\n\n        {releases.length > 0 ? (\n          <ol className=\"mt-6\">\n            {releases.map((release, index) => (\n              <ReleaseItem\n                key={release.id}\n                release={release}\n                index={index}\n                total={releases.length}\n                open={openId === release.id}\n                reduce={reduce}\n                onToggle={() =>\n                  setOpenId((current) =>\n                    current === release.id ? null : release.id\n                  )\n                }\n              />\n            ))}\n          </ol>\n        ) : (\n          <p className=\"mt-6 rounded-lg border border-dashed border-border px-4 py-8 text-center text-[13px] text-muted-foreground\">\n            Nothing shipped yet. The first release lands soon.\n          </p>\n        )}\n      </section>\n    </MotionConfig>\n  );\n}\n\nexport default ChangelogSection;\n"}]}