{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checklist",
  "title": "Checklist",
  "description": "Primitives for checklists and steppers: done, in progress, to do and skipped states, each with a marker shape and a status word, progress maths and wording that leave skipped steps out, and a styled checkbox.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/status-label.json",
    "https://www.dashboardblocks.com/r/radix/tag.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/checklist.tsx",
      "content": "'use client'\n\nimport {\n  StatusLabel,\n  type StatusTone,\n} from '@/registry/components/dashboardblocks/status-label'\nimport { Tag } from '@/registry/components/dashboardblocks/tag'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { type ComponentProps, createContext, type ReactNode, useContext } from 'react'\n\nimport { cn } from '@/lib/utils'\n\ntype StepState = 'done' | 'current' | 'todo' | 'skipped'\n\ninterface StepStateConfig {\n  icon: React.ReactNode\n  label: string\n  tone: StatusTone\n}\n\nconst stepStateConfig: Record<StepState, StepStateConfig> = {\n  current: {\n    icon: (\n      <IconPlaceholder\n        lucide='CircleDotIcon'\n        tabler='IconCircleDot'\n        hugeicons='RecordIcon'\n        phosphor='RecordIcon'\n        remixicon='RiRecordCircleLine'\n        aria-hidden\n      />\n    ),\n    label: 'In progress',\n    tone: 'info',\n  },\n  done: {\n    icon: (\n      <IconPlaceholder\n        lucide='CircleCheckIcon'\n        tabler='IconCircleCheck'\n        hugeicons='CheckmarkCircle02Icon'\n        phosphor='CheckCircleIcon'\n        remixicon='RiCheckboxCircleLine'\n        aria-hidden\n      />\n    ),\n    label: 'Done',\n    tone: 'good',\n  },\n  skipped: {\n    icon: (\n      <IconPlaceholder\n        lucide='CircleDashedIcon'\n        tabler='IconCircleDashed'\n        hugeicons='DashedLineCircleIcon'\n        phosphor='CircleDashedIcon'\n        remixicon='RiLoaderLine'\n        aria-hidden\n      />\n    ),\n    label: 'Skipped',\n    tone: 'neutral',\n  },\n  todo: {\n    icon: (\n      <IconPlaceholder\n        lucide='CircleIcon'\n        tabler='IconCircle'\n        hugeicons='CircleIcon'\n        phosphor='CircleIcon'\n        remixicon='RiCircleLine'\n        aria-hidden\n      />\n    ),\n    label: 'To do',\n    tone: 'neutral',\n  },\n}\n\ninterface ChecklistProgress {\n  done: number\n  remaining: number\n  skipped: number\n  total: number\n  /** `done` as a share of `total`, 0–100. */\n  percentage: number\n}\n\nfunction getChecklistProgress(steps: { state: StepState }[]): ChecklistProgress {\n  const done = steps.filter((step) => step.state === 'done').length\n  const skipped = steps.filter((step) => step.state === 'skipped').length\n  const total = steps.length - skipped\n  let percentage = 0\n  if (total > 0) percentage = (done / total) * 100\n  else if (steps.length > 0) percentage = 100\n  return { done, percentage, remaining: total - done, skipped, total }\n}\n\ninterface ChecklistNoun {\n  one: string\n  other: string\n}\n\nfunction describeChecklistProgress(\n  progress: ChecklistProgress,\n  noun: ChecklistNoun = { one: 'step', other: 'steps' },\n) {\n  const done = `${progress.done} of ${progress.total} ${progress.total === 1 ? noun.one : noun.other} done`\n  return progress.skipped > 0 ? `${done}, ${progress.skipped} skipped` : done\n}\n\nfunction getNextStep<T extends { state: StepState }>(steps: T[]): T | undefined {\n  return (\n    steps.find((step) => step.state === 'current') ??\n    steps.find((step) => step.state === 'todo')\n  )\n}\n\nfunction skipStep<T extends { id: string; state: StepState }>(\n  steps: T[],\n  id: string,\n): T[] {\n  const next = steps.map((step) =>\n    step.id === id ? { ...step, state: 'skipped' as const } : step,\n  )\n  if (next.some((step) => step.state === 'current')) return next\n  const index = next.findIndex((step) => step.state === 'todo')\n  return next.map((step, i) =>\n    i === index ? { ...step, state: 'current' as const } : step,\n  )\n}\n\ninterface StepIndicatorProps {\n  className?: string\n  index?: number\n  state: StepState\n}\n\nfunction StepIndicator({ className, index, state }: StepIndicatorProps) {\n  return (\n    <Tag\n      aria-hidden\n      data-state={state}\n      className={cn(\n        '[&_svg]:size-3',\n        (state === 'done' || state === 'skipped') && 'px-1',\n        state === 'done' && 'text-chart-2 bg-chart-2/10 dark:bg-chart-2/15',\n        state === 'current' && 'bg-foreground text-background',\n        className,\n      )}\n    >\n      {state === 'done' && (\n        <IconPlaceholder\n          lucide='CheckIcon'\n          tabler='IconCheck'\n          hugeicons='Tick02Icon'\n          phosphor='CheckIcon'\n          remixicon='RiCheckLine'\n          strokeWidth={2.5}\n        />\n      )}\n      {state === 'skipped' && (\n        <IconPlaceholder\n          lucide='MinusIcon'\n          tabler='IconMinus'\n          hugeicons='MinusSignIcon'\n          phosphor='MinusIcon'\n          remixicon='RiSubtractLine'\n        />\n      )}\n      {(state === 'current' || state === 'todo') &&\n        (index === undefined\n          ? state === 'current' && <span className='size-1.5 rounded-full bg-current' />\n          : index)}\n    </Tag>\n  )\n}\n\nfunction StepStateLabel({\n  className,\n  state,\n  ...props\n}: Omit<ComponentProps<typeof StatusLabel>, 'tone'> & { state: StepState }) {\n  const config = stepStateConfig[state]\n  return (\n    <StatusLabel tone={config.tone} className={className} {...props}>\n      {config.label}\n    </StatusLabel>\n  )\n}\n\nconst stepRailRow = {\n  never: { item: '', list: '' },\n  md: {\n    item: '@md:flex-1 @md:border-t-2 @md:border-l-0 @md:pt-3 @md:pl-0',\n    list: '@md:flex-row',\n  },\n  xl: {\n    item: '@xl:flex-1 @xl:border-t-2 @xl:border-l-0 @xl:pt-3 @xl:pl-0',\n    list: '@xl:flex-row',\n  },\n}\n\ntype StepRailRow = keyof typeof stepRailRow\n\nconst StepRailContext = createContext<StepRailRow>('xl')\n\n/** Steps in a column, each with a line at its start, that turn into a row with a line over each once the container is `row` wide, or never with `row='never'`. */\nfunction StepRail({\n  className,\n  row = 'xl',\n  ...props\n}: ComponentProps<'ol'> & { row?: StepRailRow }) {\n  return (\n    <StepRailContext.Provider value={row}>\n      <ol\n        data-slot='step-rail'\n        className={cn('flex flex-col gap-3', stepRailRow[row].list, className)}\n        {...props}\n      />\n    </StepRailContext.Provider>\n  )\n}\n\ninterface StepRailItemProps extends Omit<ComponentProps<'li'>, 'title'> {\n  /** A line under the title, such as when the step happened. */\n  description?: ReactNode\n  index: number\n  state: StepState\n  title: ReactNode\n}\n\nfunction StepRailItem({\n  className,\n  description,\n  index,\n  state,\n  title,\n  ...props\n}: StepRailItemProps) {\n  const row = useContext(StepRailContext)\n  return (\n    <li\n      aria-current={state === 'current' ? 'step' : undefined}\n      data-slot='step-rail-item'\n      data-state={state}\n      className={cn(\n        'border-border data-[state=current]:border-foreground data-[state=done]:border-chart-2 flex min-w-0 items-start gap-2 border-l-2 pl-3 text-sm data-[state=skipped]:border-dashed',\n        stepRailRow[row].item,\n        className,\n      )}\n      {...props}\n    >\n      <StepIndicator index={index} state={state} />\n      <span className='flex min-w-0 flex-col gap-0.5'>\n        <span\n          className={cn(\n            'min-w-0 font-medium break-words',\n            (state === 'todo' || state === 'skipped') && 'text-muted-foreground',\n          )}\n        >\n          {title}\n          <span className='sr-only'>, {stepStateConfig[state].label}</span>\n        </span>\n        {description && (\n          <span className='text-muted-foreground text-xs tabular-nums'>\n            {description}\n          </span>\n        )}\n      </span>\n    </li>\n  )\n}\n\nfunction TaskCheckbox({ className, ...props }: Omit<ComponentProps<'input'>, 'type'>) {\n  return (\n    <span className={cn('relative inline-flex size-4 shrink-0', className)}>\n      <input\n        type='checkbox'\n        className='peer border-muted-foreground/80 focus-visible:border-ring focus-visible:ring-ring/50 checked:border-primary checked:bg-primary dark:bg-input/30 dark:checked:bg-primary size-4 shrink-0 cursor-pointer appearance-none rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50'\n        {...props}\n      />\n      <IconPlaceholder\n        lucide='CheckIcon'\n        tabler='IconCheck'\n        hugeicons='Tick02Icon'\n        phosphor='CheckIcon'\n        remixicon='RiCheckLine'\n        aria-hidden\n        strokeWidth={3}\n        className='text-primary-foreground pointer-events-none absolute inset-0 z-10 m-auto hidden size-3 peer-checked:block'\n      />\n    </span>\n  )\n}\n\nexport {\n  StepIndicator,\n  StepRail,\n  StepRailItem,\n  StepStateLabel,\n  TaskCheckbox,\n  describeChecklistProgress,\n  getChecklistProgress,\n  getNextStep,\n  skipStep,\n  stepStateConfig,\n}\n\nexport type {\n  ChecklistNoun,\n  ChecklistProgress,\n  StepIndicatorProps,\n  StepRailItemProps,\n  StepState,\n  StepStateConfig,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/checklist.tsx"
    }
  ],
  "type": "registry:component"
}
