{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "task-checklist",
  "type": "registry:component",
  "title": "Task checklist",
  "description": "Actionable checklists with completion totals, per-item saving and retry feedback.",
  "categories": [
    "forms"
  ],
  "dependencies": [
    "@tabler/icons-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/task-checklist.tsx",
      "type": "registry:component",
      "target": "components/overtrue/task-checklist.tsx",
      "content": "\"use client\";\n\nimport { useId, useRef, useState, type ReactNode } from \"react\";\nimport { IconCircleCheck, IconLoader2 } from \"@tabler/icons-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface ChecklistItem {\n  id: string;\n  title: string;\n  description?: string;\n  checked: boolean;\n  disabled?: boolean;\n  meta?: ReactNode;\n}\n\nfunction ChecklistRow({\n  item,\n  onChange,\n}: {\n  item: ChecklistItem;\n  onChange?: (id: string, checked: boolean) => void | Promise<void>;\n}) {\n  const id = useId();\n  const inFlight = useRef(false);\n  const [pending, setPending] = useState(false);\n  const [error, setError] = useState(false);\n  async function change(checked: boolean) {\n    if (!onChange || inFlight.current || item.disabled) return;\n    inFlight.current = true;\n    setPending(true);\n    setError(false);\n    try {\n      await onChange(item.id, checked);\n    } catch {\n      setError(true);\n    } finally {\n      inFlight.current = false;\n      setPending(false);\n    }\n  }\n  return (\n    <li\n      data-slot=\"checklist-item\"\n      data-checked={item.checked}\n      className=\"flex items-start gap-3 py-3.5\"\n    >\n      <input\n        id={id}\n        type=\"checkbox\"\n        checked={item.checked}\n        disabled={!onChange || item.disabled || pending}\n        aria-busy={pending}\n        aria-describedby={error ? `${id}-error` : undefined}\n        onChange={(event) => void change(event.target.checked)}\n        className=\"mt-0.5 size-4 shrink-0 cursor-pointer accent-primary focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring disabled:cursor-default\"\n      />\n      <div className=\"min-w-0 flex-1\">\n        <label\n          htmlFor={id}\n          className={cn(\n            \"block cursor-pointer text-sm font-medium leading-5 [overflow-wrap:anywhere]\",\n            item.checked && \"text-muted-foreground line-through\",\n          )}\n        >\n          {item.title}\n        </label>\n        {item.description && (\n          <p className=\"m-0 mt-1 text-xs leading-5 text-muted-foreground\">\n            {item.description}\n          </p>\n        )}\n        {error && (\n          <p\n            id={`${id}-error`}\n            role=\"alert\"\n            className=\"m-0 mt-1 text-xs text-destructive\"\n          >\n            Couldn’t save this change. Try again.\n          </p>\n        )}\n      </div>\n      {pending ? (\n        <IconLoader2\n          aria-hidden=\"true\"\n          className=\"mt-0.5 size-4 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none\"\n        />\n      ) : (\n        item.meta && (\n          <div\n            data-slot=\"checklist-meta\"\n            className=\"max-w-24 shrink-0 text-right text-xs leading-5 text-muted-foreground\"\n          >\n            {item.meta}\n          </div>\n        )\n      )}\n    </li>\n  );\n}\n\n/** The caller owns completion state and persistence; failed changes stay unchecked. */\nexport function TaskChecklist({\n  title = \"Checklist\",\n  description,\n  items,\n  onCheckedChange,\n  className,\n}: {\n  title?: string;\n  description?: string;\n  items: readonly ChecklistItem[];\n  onCheckedChange?: (id: string, checked: boolean) => void | Promise<void>;\n  className?: string;\n}) {\n  const id = useId();\n  const completed = items.filter((item) => item.checked).length;\n  return (\n    <section\n      data-slot=\"task-checklist\"\n      aria-labelledby={id}\n      className={cn(\n        \"min-w-0 rounded-xl border border-border bg-card p-5 text-card-foreground\",\n        className,\n      )}\n    >\n      <div className=\"flex items-start justify-between gap-4\">\n        <div className=\"min-w-0\">\n          <h2 id={id} className=\"m-0 text-sm font-semibold\">\n            {title}\n          </h2>\n          {description && (\n            <p className=\"m-0 mt-1 text-xs leading-5 text-muted-foreground\">\n              {description}\n            </p>\n          )}\n        </div>\n        <span\n          className=\"flex shrink-0 items-center gap-1.5 text-xs tabular-nums text-muted-foreground\"\n          aria-label={`${completed} of ${items.length} completed`}\n        >\n          {items.length > 0 && completed === items.length && (\n            <IconCircleCheck\n              className=\"size-4 text-primary\"\n              aria-hidden=\"true\"\n            />\n          )}\n          {completed}/{items.length}\n        </span>\n      </div>\n      {items.length ? (\n        <>\n          <div\n            className=\"my-4 h-1 overflow-hidden rounded-full bg-muted\"\n            role=\"progressbar\"\n            aria-label={`${title} completion`}\n            aria-valuenow={completed}\n            aria-valuemin={0}\n            aria-valuemax={items.length}\n          >\n            <div\n              className=\"h-full rounded-full bg-primary transition-[width] duration-200 motion-reduce:transition-none\"\n              style={{ width: `${(completed / items.length) * 100}%` }}\n            />\n          </div>\n          <ul className=\"m-0 list-none divide-y divide-border p-0\">\n            {items.map((item) => (\n              <ChecklistRow\n                key={item.id}\n                item={item}\n                onChange={onCheckedChange}\n              />\n            ))}\n          </ul>\n        </>\n      ) : (\n        <p className=\"mb-0 mt-5 text-sm text-muted-foreground\">\n          No tasks in this checklist.\n        </p>\n      )}\n    </section>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/task-checklist. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
