{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checklist-01",
  "description": "Setup steps with a progress bar, where each step expands to show what it involves and the current step has its action.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/checklist.json",
    "https://www.dashboardblocks.com/r/radix/progress-bar.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/checklist/checklist-01.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  type StepState,\n  StepIndicator,\n  describeChecklistProgress,\n  getChecklistProgress,\n  stepStateConfig,\n  getNextStep,\n  skipStep,\n} from '@/registry/components/dashboardblocks/checklist'\nimport { ProgressBar } from '@/registry/components/dashboardblocks/progress-bar'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { useId, useState } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface OnboardingStep {\n  action?: string\n  description: string\n  duration?: string\n  id: string\n  optional?: boolean\n  state: StepState\n  title: string\n}\n\ninterface Checklist1Props extends BlockStateProps {\n  onAction?: (id: string) => void\n  onSkip?: (id: string) => void\n  /** Leave out, or pass none, to show the empty state. */\n  steps?: OnboardingStep[]\n  title: string\n}\n\ninterface ChecklistStepsProps extends Omit<Checklist1Props, 'status' | 'steps'> {\n  steps: OnboardingStep[]\n}\n\nconst exampleProps: Checklist1Props = {\n  steps: [\n    {\n      description: 'Name your workspace and pick a default currency and time zone.',\n      duration: '1 min',\n      id: 'workspace',\n      state: 'done',\n      title: 'Create your workspace',\n    },\n    {\n      action: 'Connect a source',\n      description: 'Sync data from Postgres, Stripe, HubSpot or 40 other sources.',\n      duration: '3 min',\n      id: 'source',\n      state: 'done',\n      title: 'Connect a data source',\n    },\n    {\n      action: 'Invite people',\n      description: 'Add teammates so they can view and edit dashboards.',\n      duration: '1 min',\n      id: 'team',\n      optional: true,\n      state: 'skipped',\n      title: 'Invite your team',\n    },\n    {\n      action: 'Create dashboard',\n      description:\n        'Start from a template or a blank canvas, then add the metrics you track every week.',\n      duration: '5 min',\n      id: 'dashboard',\n      state: 'current',\n      title: 'Build your first dashboard',\n    },\n    {\n      action: 'Set up alert',\n      description: 'Get an email or Slack message when a metric crosses a threshold.',\n      duration: '2 min',\n      id: 'alert',\n      optional: true,\n      state: 'todo',\n      title: 'Set up an alert',\n    },\n    {\n      action: 'Schedule report',\n      description: 'Send a weekly summary to your inbox every Monday morning.',\n      duration: '2 min',\n      id: 'report',\n      state: 'todo',\n      title: 'Schedule a report',\n    },\n  ],\n  title: 'Get started',\n}\n\nfunction ChecklistSteps(props: ChecklistStepsProps) {\n  const { onAction, onSkip, title } = props\n  const id = useId()\n  const [steps, setSteps] = useState(props.steps)\n  const [expanded, setExpanded] = useState(() => {\n    const next = getNextStep(props.steps)\n    return new Set(next ? [next.id] : [])\n  })\n  const [announcement, setAnnouncement] = useState('')\n  const progress = getChecklistProgress(steps)\n  const nextStep = getNextStep(steps)\n\n  const toggle = (stepId: string) => {\n    setExpanded((current) => {\n      const next = new Set(current)\n      if (next.has(stepId)) next.delete(stepId)\n      else next.add(stepId)\n      return next\n    })\n  }\n\n  const skip = (step: OnboardingStep) => {\n    const nextSteps = skipStep(steps, step.id)\n    const next = getNextStep(nextSteps)\n    setSteps(nextSteps)\n    setExpanded((current) => {\n      const updated = new Set(current)\n      updated.delete(step.id)\n      if (next) updated.add(next.id)\n      return updated\n    })\n    setAnnouncement(\n      next ? `Skipped ${step.title}. Next: ${next.title}` : `Skipped ${step.title}`,\n    )\n    onSkip?.(step.id)\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)}.{nextStep && ` Next: ${nextStep.title}.`}\n        </p>\n      </header>\n      <div\n        role='progressbar'\n        aria-label={title}\n        aria-valuemax={progress.total}\n        aria-valuemin={0}\n        aria-valuenow={progress.done}\n        aria-valuetext={describeChecklistProgress(progress)}\n      >\n        <ProgressBar\n          className='h-1.5'\n          fillClassName='motion-reduce:transition-none'\n          percentage={progress.percentage}\n        />\n      </div>\n      <p role='status' className='sr-only'>\n        {announcement}\n      </p>\n      <ol className='border-t'>\n        {steps.map((step, index) => {\n          const isOpen = expanded.has(step.id)\n          const panelId = `${id}-${step.id}`\n          return (\n            <li key={step.id} className='border-b last:border-b-0'>\n              <button\n                type='button'\n                aria-controls={panelId}\n                aria-current={step.state === 'current' ? 'step' : undefined}\n                aria-expanded={isOpen}\n                onClick={() => toggle(step.id)}\n                className='group/step focus-visible:ring-ring/50 flex w-full items-start gap-3 rounded-md py-2.5 text-left outline-none focus-visible:ring-3'\n              >\n                <StepIndicator index={index + 1} state={step.state} />\n                <span className='flex min-w-0 flex-1 flex-col gap-0.5'>\n                  <span\n                    className={cn(\n                      'text-sm font-medium group-hover/step:underline group-hover/step:underline-offset-4',\n                      (step.state === 'done' || step.state === 'skipped') &&\n                        'text-muted-foreground',\n                    )}\n                  >\n                    {step.title}\n                    <span className='sr-only'>, {stepStateConfig[step.state].label}</span>\n                  </span>\n                  {step.optional && (\n                    <span className='text-muted-foreground text-sm'>Optional</span>\n                  )}\n                </span>\n                {step.duration && (\n                  <span className='text-muted-foreground shrink-0 text-sm tabular-nums'>\n                    {step.duration}\n                  </span>\n                )}\n                <IconPlaceholder\n                  lucide='ChevronDownIcon'\n                  tabler='IconChevronDown'\n                  hugeicons='ArrowDownIcon'\n                  phosphor='CaretDownIcon'\n                  remixicon='RiArrowDownSLine'\n                  aria-hidden\n                  className={cn(\n                    'text-muted-foreground mt-0.5 size-4 shrink-0 transition-transform motion-reduce:transition-none',\n                    isOpen && 'rotate-180',\n                  )}\n                />\n              </button>\n              <div id={panelId} hidden={!isOpen} className='pr-7 pb-3 pl-8'>\n                <p className='text-muted-foreground text-sm'>{step.description}</p>\n                {step.state !== 'done' && (step.action || step.optional) && (\n                  <div className='mt-3 flex flex-wrap gap-2'>\n                    {step.action && (\n                      <Button\n                        size='sm'\n                        variant={step.state === 'current' ? 'default' : 'outline'}\n                        onClick={() => onAction?.(step.id)}\n                      >\n                        {step.action}\n                      </Button>\n                    )}\n                    {step.optional && step.state !== 'skipped' && (\n                      <Button\n                        size='sm'\n                        variant='ghost'\n                        onClick={() => skip(step)}\n                        aria-label={`Skip ${step.title}`}\n                      >\n                        Skip\n                      </Button>\n                    )}\n                  </div>\n                )}\n              </div>\n            </li>\n          )\n        })}\n      </ol>\n    </section>\n  )\n}\n\nconst Checklist1 = (props: Checklist1Props) => {\n  const { errorMessage, status, steps = [], title } = props\n  const state = getBlockState(status, steps)\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            <ChecklistSteps {...props} steps={steps} />\n          )}\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Checklist1, exampleProps as checklist1ExampleProps, type Checklist1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/checklist/checklist-01.tsx"
    }
  ],
  "meta": {
    "shows": "Setup steps with a progress bar, where each step expands to show what it involves and the current step has its action.",
    "size": "half",
    "usedWith": [
      "checklist-03",
      "onboarding-01"
    ],
    "component": "Checklist1",
    "props": "{ onAction?: (id: string) => void; onSkip?: (id: string) => void; steps?: { action?: string; description: string; duration?: string; id: string; optional?: boolean; state: \"done\" | \"todo\" | \"current\" | \"skipped\"; title: string }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
