{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"stepper","type":"registry:block","title":"Stepper","description":"A four-step setup stepper with a filling rail, completed checks, an animated detail panel and Back/Continue controls.","dependencies":["motion","lucide-react"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/stepper/stepper.tsx","type":"registry:component","content":"\"use client\";\n\nimport { useRef, useState } from \"react\";\nimport {\n  AnimatePresence,\n  MotionConfig,\n  motion,\n  useInView,\n  useReducedMotion,\n} from \"motion/react\";\nimport { ArrowLeft, ArrowRight, Check } 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 StepperStep = {\n  id: string;\n  title: string;\n  description?: string;\n  optional?: boolean;\n};\n\nexport type StepperProps = {\n  className?: string;\n  title?: string;\n  description?: string;\n  steps?: StepperStep[];\n  defaultStep?: number;\n  onStepChange?: (index: number) => void;\n  onComplete?: () => void;\n};\n\n/* ------------------------------------------------------------------ */\n/* deterministic demo data                                             */\n/* ------------------------------------------------------------------ */\n\nconst DEFAULT_STEPS: StepperStep[] = [\n  {\n    id: \"source\",\n    title: \"Connect data\",\n    description:\n      \"Point PrequelUI at your warehouse. We read the schema, never the rows, and keep every query inside your account.\",\n  },\n  {\n    id: \"metrics\",\n    title: \"Pick metrics\",\n    description:\n      \"Choose the numbers the team checks every morning. Start with revenue, activation and churn — you can change them later.\",\n  },\n  {\n    id: \"team\",\n    title: \"Invite the team\",\n    description:\n      \"Three seats are included on the Studio plan. Invite the people who act on these numbers, not everyone who asks for them.\",\n  },\n  {\n    id: \"publish\",\n    title: \"Publish\",\n    description:\n      \"Ship the dashboard to a private link, or embed it in the tools your team already opens every day.\",\n  },\n];\n\n/* ------------------------------------------------------------------ */\n/* block                                                               */\n/* ------------------------------------------------------------------ */\n\nexport function Stepper({\n  className,\n  title = \"Set up your workspace\",\n  description = \"Four steps, about three minutes. You can leave and come back at any point.\",\n  steps = DEFAULT_STEPS,\n  defaultStep = 2,\n  onStepChange,\n  onComplete,\n}: StepperProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const inView = useInView(ref, { once: true, margin: \"-10% 0px\" });\n  const reduce = Boolean(useReducedMotion());\n\n  const count = Math.max(1, steps.length);\n  const [step, setStep] = useState(() => Math.min(count - 1, Math.max(0, defaultStep)));\n  const [done, setDone] = useState(false);\n\n  const activeStep = steps[Math.min(step, count - 1)];\n  const last = step === count - 1;\n  const railProgress = count > 1 ? step / (count - 1) : 1;\n\n  const goTo = (next: number) => {\n    const target = Math.min(count - 1, Math.max(0, next));\n    setDone(false);\n    setStep(target);\n    onStepChange?.(target);\n  };\n\n  const next = () => {\n    if (!last) {\n      goTo(step + 1);\n      return;\n    }\n    setDone(true);\n    onComplete?.();\n  };\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <div ref={ref} className={cn(\"w-full\", className)}>\n        <motion.div\n          initial={{ opacity: 0, y: reduce ? 0 : 16 }}\n          animate={{ opacity: inView ? 1 : 0, y: 0 }}\n          transition={{ duration: reduce ? 0 : 0.55, ease: EASE }}\n          className=\"rounded-xl border border-border bg-card p-5 text-card-foreground shadow-sm sm:p-6\"\n        >\n          <div className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-2\">\n            <div className=\"min-w-0\">\n              <h2 className=\"text-[15px] font-semibold tracking-tight\">{title}</h2>\n              <p className=\"mt-0.5 max-w-lg text-[12.5px] leading-5 text-muted-foreground\">\n                {description}\n              </p>\n            </div>\n            <span\n              className={cn(\n                \"inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium tabular-nums\",\n                done\n                  ? \"border-success/25 bg-success/10 text-success\"\n                  : \"border-border text-muted-foreground\"\n              )}\n            >\n              {done ? (\n                <>\n                  <Check className=\"h-3 w-3\" strokeWidth={3} aria-hidden=\"true\" />\n                  Complete\n                </>\n              ) : (\n                `Step ${step + 1} of ${count}`\n              )}\n            </span>\n          </div>\n\n          <div className=\"mt-6\">\n            <div className=\"relative\">\n              <div\n                className=\"absolute top-4 h-px bg-border\"\n                style={{ left: `${50 / count}%`, right: `${50 / count}%` }}\n              />\n              <motion.div\n                aria-hidden=\"true\"\n                initial={{ scaleX: reduce ? railProgress : 0 }}\n                animate={{ scaleX: inView ? railProgress : 0 }}\n                transition={{ duration: reduce ? 0 : 0.45, ease: EASE, delay: reduce ? 0 : 0.1 }}\n                style={{\n                  transformOrigin: \"left center\",\n                  left: `${50 / count}%`,\n                  right: `${50 / count}%`,\n                }}\n                className=\"absolute top-4 h-px bg-foreground\"\n              />\n\n              <ol\n                className=\"relative grid gap-1\"\n                style={{ gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` }}\n              >\n                {steps.map((item, index) => {\n                  const completed = done || index < step;\n                  const active = !done && index === step;\n\n                  return (\n                    <li key={item.id} className=\"flex min-w-0 flex-col items-center\">\n                      <button\n                        type=\"button\"\n                        onClick={() => goTo(index)}\n                        aria-label={`Step ${index + 1} of ${count}: ${item.title}`}\n                        aria-current={active ? \"step\" : undefined}\n                        className={cn(\n                          \"relative flex h-8 w-8 items-center justify-center rounded-full border text-[12px] font-medium tabular-nums 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                          completed\n                            ? \"border-foreground bg-foreground text-background\"\n                            : active\n                              ? \"border-foreground bg-card text-foreground\"\n                              : \"border-border bg-card text-muted-foreground hover:border-foreground/30 hover:text-foreground\"\n                        )}\n                      >\n                        {completed ? (\n                          <Check className=\"h-3.5 w-3.5\" strokeWidth={3} aria-hidden=\"true\" />\n                        ) : (\n                          <span>{index + 1}</span>\n                        )}\n\n                        {active && !reduce ? (\n                          <motion.span\n                            key={`pulse-${step}`}\n                            aria-hidden=\"true\"\n                            initial={{ scale: 0.85, opacity: 0.5 }}\n                            animate={{ scale: 1.7, opacity: 0 }}\n                            transition={{ duration: 0.8, ease: \"easeOut\" }}\n                            className=\"pointer-events-none absolute inset-0 rounded-full ring-1 ring-foreground\"\n                          />\n                        ) : null}\n                      </button>\n\n                      <span\n                        className={cn(\n                          \"mt-2 min-w-0 text-center text-[11px] leading-4 sm:text-[11.5px]\",\n                          active ? \"font-medium text-foreground\" : \"text-muted-foreground\"\n                        )}\n                      >\n                        {item.title}\n                        {item.optional ? (\n                          <span className=\"block text-[10px] text-muted-foreground/70\">Optional</span>\n                        ) : null}\n                      </span>\n                    </li>\n                  );\n                })}\n              </ol>\n            </div>\n          </div>\n\n          <div className=\"mt-6 rounded-lg border border-border bg-muted/20 p-4\">\n            <AnimatePresence mode=\"wait\" initial={false}>\n              {done ? (\n                <motion.div\n                  key=\"done\"\n                  initial={reduce ? false : { opacity: 0, y: 6 }}\n                  animate={{ opacity: 1, y: 0 }}\n                  exit={{ opacity: 0 }}\n                  transition={{ duration: reduce ? 0 : 0.3, ease: EASE }}\n                  aria-live=\"polite\"\n                >\n                  <div className=\"flex items-start gap-3\">\n                    <span className=\"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-success/10 text-success\">\n                      <Check className=\"h-3.5 w-3.5\" strokeWidth={3} aria-hidden=\"true\" />\n                    </span>\n                    <div className=\"min-w-0\">\n                      <p className=\"text-[13px] font-medium text-foreground\">Dashboard published</p>\n                      <p className=\"mt-1 text-[12.5px] leading-5 text-muted-foreground\">\n                        Northwind Labs can open it from the Showcase. Invitees get an email with the\n                        private link.\n                      </p>\n                    </div>\n                  </div>\n                  <div className=\"mt-4 flex flex-wrap items-center justify-between gap-2\">\n                    <a\n                      href=\"/showcase\"\n                      className=\"inline-flex h-9 items-center gap-1.5 rounded-lg bg-foreground px-3.5 text-[12.5px] font-medium text-background transition-colors hover:bg-foreground/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n                    >\n                      Open showcase\n                      <ArrowRight className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n                    </a>\n                    <button\n                      type=\"button\"\n                      onClick={() => goTo(0)}\n                      className=\"inline-flex h-9 items-center gap-1.5 rounded-lg border border-border bg-background px-3.5 text-[12.5px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n                    >\n                      <ArrowLeft className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n                      Start over\n                    </button>\n                  </div>\n                </motion.div>\n              ) : (\n                <motion.div\n                  key={`step-${step}`}\n                  initial={reduce ? false : { opacity: 0, y: 6 }}\n                  animate={{ opacity: 1, y: 0 }}\n                  exit={{ opacity: 0 }}\n                  transition={{ duration: reduce ? 0 : 0.28, ease: EASE }}\n                  aria-live=\"polite\"\n                >\n                  <p className=\"text-[13px] font-medium text-foreground\">\n                    {activeStep?.title}\n                    {activeStep?.optional ? (\n                      <span className=\"ml-2 text-[11px] font-normal text-muted-foreground\">\n                        Optional\n                      </span>\n                    ) : null}\n                  </p>\n                  <p className=\"mt-1 text-[12.5px] leading-5 text-muted-foreground\">\n                    {activeStep?.description}\n                  </p>\n\n                  <div className=\"mt-4 flex items-center justify-between gap-2\">\n                    <button\n                      type=\"button\"\n                      onClick={() => goTo(step - 1)}\n                      disabled={step === 0}\n                      className=\"inline-flex h-9 items-center gap-1.5 rounded-lg border border-border bg-background px-3.5 text-[12.5px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card disabled:pointer-events-none disabled:opacity-40\"\n                    >\n                      <ArrowLeft className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n                      Back\n                    </button>\n                    <button\n                      type=\"button\"\n                      onClick={next}\n                      className=\"inline-flex h-9 items-center gap-1.5 rounded-lg bg-foreground px-3.5 text-[12.5px] font-medium text-background transition-colors hover:bg-foreground/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n                    >\n                      {last ? \"Publish dashboard\" : \"Continue\"}\n                      <ArrowRight className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n                    </button>\n                  </div>\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </div>\n        </motion.div>\n      </div>\n    </MotionConfig>\n  );\n}\n\nexport default Stepper;\n"}]}