{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "setup-checklist",
  "type": "registry:ui",
  "title": "Setup Checklist",
  "description": "The few things a new member does to get going (add a photo, pick topics, try a first game), in a card that shows how far they are and what to do next. Tasks can be done in any order; the first one not yet done is the next, and it is the one the card puts…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "feedback",
    "pattern"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/button.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/patterns/setup-checklist.tsx",
      "target": "components/ui/patterns/setup-checklist.tsx",
      "type": "registry:ui",
      "content": "'use client';\n\nimport * as React from 'react';\n\n// @interlace/setup-checklist v1.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/setup-checklist\n// What changed since: https://ds.interlace.tools/c/setup-checklist#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — SetupChecklist, SetupTask\n *\n * The few things a new member does to get going (add a photo, pick topics,\n * try a first game), in a card that shows how far they are and what to do\n * next. Tasks can be done in any order; the first one not yet done is the\n * next, and it is the one the card puts forward: by default only it shows\n * its description and action, so the card asks for one thing at a time\n * (`expand=\"all\"` opens every undone task). When every task is done the\n * card says so, and can be put away.\n *\n * ## Content first\n *\n * The card is a `section` named by its title, the tasks an ordered list.\n * Each done task says \"Done\" in words, not only with its tick. The progress\n * bar is a `progressbar` whose value is read as \"2 of 5 done\", and the same\n * words sit beside it, in a polite live region, so finishing a task is heard.\n * The next task carries `aria-current=\"step\"`.\n *\n * ## Motion\n *\n * The bar grows to its new length and a task's tick pops in when it is done,\n * timed by `--duration-medium` on `--ease-enter`. A task already done when\n * the card first paints is simply ticked. Under reduced motion both simply\n * change.\n *\n * ## MIN_VIEWPORT — 320\n *\n * A task's action sits under its words, so nothing has to share a narrow row.\n *\n * ## Anatomy\n *\n *   SetupChecklist                 (section — data-slot=\"setup-checklist\", data-complete)\n *     ├─ header\n *     │   ├─ title                 (h2 — data-slot=\"setup-checklist-title\")\n *     │   ├─ description?\n *     │   └─ dismiss?              (Button — when complete and `onDismiss` is given)\n *     ├─ progress                  (data-slot=\"setup-checklist-progress\": count in words + bar)\n *     └─ ol\n *         └─ SetupTask × n         (li — data-slot=\"setup-task\", data-done, data-next, aria-current)\n *             ├─ mark              (tick when done, ring otherwise, aria-hidden)\n *             ├─ title + \"Done\"    (sr-only when done)\n *             ├─ reward?           (e.g. \"+20 XP\")\n *             ├─ description?      (shown on the next task, or every undone one with expand=\"all\")\n *             └─ action?           (the same, e.g. a link or button)\n *\n * | Rule | Concept                 | Where in this file                                  |\n * | ---- | ----------------------- | --------------------------------------------------- |\n * | R4   | Extends native el       | `section` / `li` props                               |\n * | R6   | data-slot per part      | setup-checklist / -title / -progress / setup-task    |\n * | R7   | cn + ...rest            | `cn(BASE, className)` + `{...props}`                 |\n * | R14  | Declares min viewport   | `data-min-viewport` + exported const                 |\n * | R19  | Tokens only             | `--primary`, `--muted`, `--duration-medium`          |\n * | R26  | A11y from native el     | named section, ol, progressbar, words for each state |\n */\n\nimport { CheckIcon } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { Button } from '@/components/ui/button';\n\n/** Smallest viable viewport (CSS px) for this pattern. */\nexport const MIN_VIEWPORT = 320 as const;\n\nexport interface SetupTaskProps extends Omit<React.ComponentPropsWithoutRef<'li'>, 'title'> {\n  /** What to do, e.g. \"Add a profile photo\". */\n  title: React.ReactNode;\n  /** One line on why or how, shown while the task is not done. */\n  description?: React.ReactNode;\n  /** Whether the member has done it. */\n  done?: boolean;\n  /** What doing it does, e.g. a link or button; shown while the task is not done. */\n  action?: React.ReactNode;\n  /** What doing it earns, e.g. \"+20 XP\". */\n  reward?: React.ReactNode;\n  /** The word said for a done task. @default 'Done' */\n  doneLabel?: string;\n}\n\ninterface TaskPlace {\n  next: boolean;\n  /** Whether undone tasks other than the next show their description and action. */\n  expandAll: boolean;\n}\n\nconst TaskContext = React.createContext<TaskPlace | null>(null);\n\nexport function SetupTask({\n  title,\n  description,\n  done = false,\n  action,\n  reward,\n  doneLabel = 'Done',\n  className,\n  ...props\n}: SetupTaskProps) {\n  const place = React.useContext(TaskContext);\n  const next = place?.next ?? false;\n  const open = !done && (next || (place?.expandAll ?? true));\n  // A task already done when the card first paints is simply ticked; only one done here pops.\n  const [doneAtFirst] = React.useState(done);\n  return (\n    <li\n      data-slot=\"setup-task\"\n      data-done={done ? '' : undefined}\n      data-next={next ? '' : undefined}\n      aria-current={next ? 'step' : undefined}\n      className={cn(\n        'grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-lg px-3 py-2.5',\n        'data-[next]:bg-muted/60',\n        className,\n      )}\n      {...props}\n    >\n      <span\n        aria-hidden=\"true\"\n        data-slot=\"setup-task-mark\"\n        className={cn(\n          'mt-0.5 flex size-5 items-center justify-center rounded-full border',\n          done ? 'bg-primary border-primary text-primary-foreground' : 'border-input',\n          next && 'border-primary border-2',\n        )}\n      >\n        {done ? (\n          <CheckIcon\n            className={cn(\n              'size-3.5',\n              !doneAtFirst &&\n                'motion-safe:animate-in motion-safe:zoom-in-50 motion-safe:duration-(--duration-medium) motion-safe:ease-enter',\n            )}\n          />\n        ) : null}\n      </span>\n      <div className=\"flex min-w-0 flex-wrap items-baseline justify-between gap-x-3\">\n        <span data-slot=\"setup-task-title\" className={cn('font-medium', done && 'text-muted-foreground font-normal')}>\n          {title}\n          {done ? <span className=\"sr-only\">{`, ${doneLabel}`}</span> : null}\n        </span>\n        {reward ? (\n          <span data-slot=\"setup-task-reward\" className=\"text-muted-foreground shrink-0 text-sm tabular-nums\">\n            {reward}\n          </span>\n        ) : null}\n      </div>\n      {open && (description || action) ? (\n        <div className=\"col-start-2 flex flex-col items-start gap-2\">\n          {description ? <p className=\"text-muted-foreground text-sm\">{description}</p> : null}\n          {action ? <div data-slot=\"setup-task-action\">{action}</div> : null}\n        </div>\n      ) : null}\n    </li>\n  );\n}\n\nexport interface SetupChecklistProps extends Omit<React.ComponentPropsWithoutRef<'section'>, 'title'> {\n  /** The card's heading, e.g. \"Get started\". */\n  title: React.ReactNode;\n  /** One line under it. */\n  description?: React.ReactNode;\n  /** The heading once every task is done. Defaults to `title`. */\n  completeTitle?: React.ReactNode;\n  /** The line once every task is done. */\n  completeDescription?: React.ReactNode;\n  /** Put the card away; offered once every task is done. */\n  onDismiss?: () => void;\n  /** The dismiss button's words. @default 'Close' */\n  dismissLabel?: string;\n  /** The progress in words. @default (done, total) => `${done} of ${total} done` */\n  progressLabel?: (done: number, total: number) => string;\n  /**\n   * Which undone tasks show their description and action: only the next one,\n   * so the card asks for one thing at a time, or all of them. @default 'next'\n   */\n  expand?: 'next' | 'all';\n  /** Heading level for the title. @default 2 */\n  headingLevel?: 2 | 3 | 4;\n  /** `SetupTask`s, in the order the member should do them. */\n  children?: React.ReactNode;\n}\n\nexport function SetupChecklist({\n  title,\n  description,\n  completeTitle,\n  completeDescription,\n  onDismiss,\n  dismissLabel = 'Close',\n  progressLabel = (done, total) => `${done} of ${total} done`,\n  headingLevel = 2,\n  expand = 'next',\n  className,\n  children,\n  ...props\n}: SetupChecklistProps) {\n  const id = React.useId();\n  const tasks = React.Children.toArray(children).filter(React.isValidElement<SetupTaskProps>);\n  const total = tasks.length;\n  const done = tasks.filter((task) => task.props.done).length;\n  const nextIndex = tasks.findIndex((task) => !task.props.done);\n  const complete = total > 0 && done === total;\n  const Heading = `h${headingLevel}` as const;\n  const words = progressLabel(done, total);\n\n  return (\n    <section\n      data-slot=\"setup-checklist\"\n      data-min-viewport={String(MIN_VIEWPORT)}\n      data-complete={complete ? '' : undefined}\n      aria-labelledby={`${id}-title`}\n      className={cn('bg-card text-card-foreground flex flex-col gap-4 rounded-xl border p-4 sm:p-5', className)}\n      {...props}\n    >\n      <div className=\"flex items-start justify-between gap-3\">\n        <div className=\"flex min-w-0 flex-col gap-1\">\n          <Heading id={`${id}-title`} data-slot=\"setup-checklist-title\" className=\"text-lg font-semibold\">\n            {complete && completeTitle ? completeTitle : title}\n          </Heading>\n          {(complete ? (completeDescription ?? description) : description) ? (\n            <p className=\"text-muted-foreground text-sm\">\n              {complete ? (completeDescription ?? description) : description}\n            </p>\n          ) : null}\n        </div>\n        {complete && onDismiss ? (\n          <Button type=\"button\" variant=\"ghost\" size=\"sm\" data-slot=\"setup-checklist-dismiss\" onClick={onDismiss}>\n            {dismissLabel}\n          </Button>\n        ) : null}\n      </div>\n\n      <div data-slot=\"setup-checklist-progress\" className=\"flex items-center gap-3\">\n        <div\n          role=\"progressbar\"\n          aria-labelledby={`${id}-title`}\n          aria-valuemin={0}\n          aria-valuemax={total}\n          aria-valuenow={done}\n          aria-valuetext={words}\n          className=\"bg-foreground/10 h-2 flex-1 overflow-hidden rounded-full\"\n        >\n          <div\n            className=\"bg-primary h-full origin-left rounded-full transition-transform duration-(--duration-medium) ease-enter motion-reduce:transition-none rtl:origin-right\"\n            style={{ transform: `scaleX(${total ? done / total : 0})` }}\n          />\n        </div>\n        <p aria-live=\"polite\" className=\"text-muted-foreground shrink-0 text-sm tabular-nums\">\n          {words}\n        </p>\n      </div>\n\n      <ol className=\"-mx-3 flex flex-col gap-1\">\n        {tasks.map((task, index) => (\n          <TaskContext.Provider key={task.key} value={{ next: index === nextIndex, expandAll: expand === 'all' }}>\n            {task}\n          </TaskContext.Provider>\n        ))}\n      </ol>\n    </section>\n  );\n}\n"
    }
  ],
  "meta": {
    "tier": "pattern",
    "client": true,
    "minViewport": 320,
    "loading": false,
    "version": "1.0.0",
    "since": null
  },
  "docs": "## @interlace/setup-checklist\n\nInstalled to `components/ui/patterns/setup-checklist.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/patterns/setup-checklist';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/setup-checklist\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
