{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checklist-04",
  "description": "Tasks grouped by team with owners, due dates and checkboxes, with overdue and due-soon tasks written in colour.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/checklist.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/progress-bar.json",
    "https://www.dashboardblocks.com/r/radix/schedule.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/checklist/checklist-04.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  TaskCheckbox,\n  describeChecklistProgress,\n  getChecklistProgress,\n} from '@/registry/components/dashboardblocks/checklist'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport { ProgressBar } from '@/registry/components/dashboardblocks/progress-bar'\nimport { DueLabel, getDayOffset } from '@/registry/components/dashboardblocks/schedule'\nimport { useId, useState } from 'react'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface Task {\n  done?: boolean\n  due: Date\n  id: string\n  owner?: string\n  title: string\n}\n\ninterface TaskGroup {\n  name: string\n  tasks: Task[]\n}\n\ninterface Checklist4Props extends BlockStateProps {\n  /** Leave out, or pass none, to show the empty state. */\n  groups?: TaskGroup[]\n  now: Date\n  onToggle?: (id: string, done: boolean) => void\n  title: string\n}\n\ninterface TaskGroupsProps extends Omit<Checklist4Props, 'groups' | 'status'> {\n  groups: TaskGroup[]\n}\n\nconst NOW = Date.UTC(2026, 8, 26, 9, 0)\nconst day = (offset: number) => new Date(NOW + offset * 86_400_000)\n\nconst exampleProps: Checklist4Props = {\n  groups: [\n    {\n      name: 'Product',\n      tasks: [\n        {\n          done: true,\n          due: day(-6),\n          id: 't1',\n          owner: 'Maya',\n          title: 'Freeze pricing page copy',\n        },\n        {\n          done: true,\n          due: day(-3),\n          id: 't2',\n          owner: 'Leo',\n          title: 'Ship plan picker to 100%',\n        },\n        {\n          due: day(-1),\n          id: 't3',\n          owner: 'Leo',\n          title: 'Migrate legacy annual plans',\n        },\n      ],\n    },\n    {\n      name: 'Marketing',\n      tasks: [\n        {\n          done: true,\n          due: day(-2),\n          id: 't4',\n          owner: 'Ana',\n          title: 'Record launch demo video',\n        },\n        { due: day(0), id: 't5', owner: 'Ana', title: 'Schedule launch email' },\n        {\n          due: day(3),\n          id: 't6',\n          owner: 'Sam',\n          title: 'Publish launch blog post',\n        },\n      ],\n    },\n    {\n      name: 'Support',\n      tasks: [\n        {\n          done: true,\n          due: day(-4),\n          id: 't7',\n          owner: 'Kai',\n          title: 'Update billing FAQ',\n        },\n        {\n          due: day(2),\n          id: 't8',\n          owner: 'Kai',\n          title: 'Brief the support team',\n        },\n      ],\n    },\n  ],\n  now: new Date(NOW),\n  title: 'Pricing launch',\n}\n\nconst SOON_DAYS = 2\n\nfunction TaskGroups(props: TaskGroupsProps) {\n  const { groups, now, onToggle, title } = props\n  const id = useId()\n  const [done, setDone] = useState(\n    () =>\n      new Set(\n        groups.flatMap((group) =>\n          group.tasks.filter((task) => task.done).map((task) => task.id),\n        ),\n      ),\n  )\n  const [announcement, setAnnouncement] = useState('')\n  const tasks = groups.flatMap((group) => group.tasks)\n  const progress = getChecklistProgress(\n    tasks.map((task) => ({ state: done.has(task.id) ? 'done' : 'todo' })),\n  )\n  const overdue = tasks.filter(\n    (task) => !done.has(task.id) && getDayOffset(task.due, now) < 0,\n  ).length\n\n  const toggle = (task: Task, checked: boolean) => {\n    setDone((current) => {\n      const next = new Set(current)\n      if (checked) next.add(task.id)\n      else next.delete(task.id)\n      return next\n    })\n    setAnnouncement(`${task.title} marked ${checked ? 'done' : 'not done'}`)\n    onToggle?.(task.id, checked)\n  }\n\n  return (\n    <section className='@container flex flex-col gap-3'>\n      <header className='flex flex-col gap-0.5'>\n        <h2 className='font-semibold tracking-tight'>{title}</h2>\n        <p className='text-muted-foreground text-sm'>\n          {describeChecklistProgress(progress, { one: 'task', other: 'tasks' })}\n          {overdue > 0 ? `, ${overdue} overdue.` : '.'}\n        </p>\n      </header>\n      <p role='status' className='sr-only'>\n        {announcement}\n      </p>\n      <div aria-hidden>\n        <ProgressBar\n          className='h-1.5'\n          fillClassName='motion-reduce:transition-none'\n          percentage={progress.percentage}\n        />\n      </div>\n      <div className='flex flex-col gap-4'>\n        {groups.map((group, groupIndex) => {\n          const headingId = `${id}-group-${groupIndex}`\n          const groupDone = group.tasks.filter((task) => done.has(task.id)).length\n          return (\n            <section\n              key={group.name}\n              aria-labelledby={headingId}\n              className='flex flex-col'\n            >\n              <h3\n                id={headingId}\n                className='flex items-baseline justify-between gap-3 border-b pb-2 text-sm font-medium'\n              >\n                {group.name}\n                {/* Not a count: the group's progress, written as words */}\n                <span className='text-muted-foreground font-normal tabular-nums'>\n                  {groupDone} of {group.tasks.length} done\n                </span>\n              </h3>\n              <ul>\n                {group.tasks.map((task) => {\n                  const checkboxId = `${id}-${task.id}`\n                  const metaId = `${checkboxId}-meta`\n                  const isDone = done.has(task.id)\n                  return (\n                    <li\n                      key={task.id}\n                      className='flex items-start gap-3 border-b py-2.5 last:border-b-0'\n                    >\n                      <TaskCheckbox\n                        id={checkboxId}\n                        checked={isDone}\n                        aria-describedby={metaId}\n                        className='mt-0.5'\n                        onChange={(event) => toggle(task, event.target.checked)}\n                      />\n                      <div className='flex min-w-0 flex-1 flex-col gap-0.5 @md:flex-row @md:items-baseline @md:justify-between @md:gap-3'>\n                        <label\n                          htmlFor={checkboxId}\n                          className={cn(\n                            'cursor-pointer text-sm',\n                            isDone && 'text-muted-foreground line-through',\n                          )}\n                        >\n                          {task.title}\n                        </label>\n                        <Details\n                          id={metaId}\n                          className='text-muted-foreground text-sm @md:shrink-0'\n                        >\n                          {task.owner}\n                          <DueLabel\n                            done={isDone}\n                            due={task.due}\n                            now={now}\n                            soonDays={SOON_DAYS}\n                          />\n                        </Details>\n                      </div>\n                    </li>\n                  )\n                })}\n              </ul>\n            </section>\n          )\n        })}\n      </div>\n    </section>\n  )\n}\n\nconst Checklist4 = (props: Checklist4Props) => {\n  const { groups = [], errorMessage, status, title } = props\n  const state = getBlockState(\n    status,\n    groups.flatMap((group) => group.tasks),\n  )\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          {state ? (\n            <section className='@container flex flex-col gap-3'>\n              <header className='flex flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{title}</h2>\n                {state === 'loading' && (\n                  <span className='text-sm'>\n                    <SkeletonText className='w-2/3' />\n                  </span>\n                )}\n              </header>\n              {state === 'loading' && <ProgressBar className='h-1.5' percentage={0} />}\n              <BlockStateRows className='border-t' rows={6} />\n            </section>\n          ) : (\n            <TaskGroups {...props} groups={groups} />\n          )}\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Checklist4, exampleProps as checklist4ExampleProps, type Checklist4Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/checklist/checklist-04.tsx"
    }
  ],
  "meta": {
    "shows": "Tasks grouped by team with owners, due dates and checkboxes, with overdue and due-soon tasks written in colour.",
    "size": "half",
    "usedWith": [
      "schedule-03",
      "kanban-01",
      "team-02"
    ],
    "component": "Checklist4",
    "props": "{ groups?: { name: string; tasks: { done?: boolean; due: Date; id: string; owner?: string; title: string }[] }[]; now: Date; onToggle?: (id: string, done: boolean) => void; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
