{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kanban-02",
  "description": "A sales board of deals in columns, each column showing its total value and each deal its next step.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/kanban.json",
    "https://www.dashboardblocks.com/r/radix/pipeline.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/kanban/kanban-02.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  KanbanAssignees,\n  KanbanBoard,\n  KanbanCard,\n  KanbanCardMenu,\n  KanbanCardTitle,\n  KanbanColumn,\n  type KanbanColumnDef,\n  KanbanDueDate,\n  type KanbanItem,\n  getColumnItems,\n  moveItem,\n} from '@/registry/components/dashboardblocks/kanban'\nimport { getStageColor } from '@/registry/components/dashboardblocks/pipeline'\nimport { formatCurrency } from '@/registry/lib/dashboardblocks/format'\nimport { useMemo, useState } from 'react'\n\ninterface Deal extends KanbanItem {\n  description: string\n  nextStep: string\n  nextStepAt: Date\n  owner: string\n  value: number\n}\n\ninterface Kanban2Props extends BlockStateProps {\n  closedColumns: { lost: string; won: string }\n  columns: KanbanColumnDef[]\n  /** Leave out, or pass none, to show the empty state. */\n  deals?: Deal[]\n  /** Pass a fixed date, so next-step dates render the same on the server and in the browser. */\n  now: Date\n  onMove?: (id: string, column: string, index: number) => void\n  title: string\n}\n\nconst NOW = Date.UTC(2026, 8, 28, 10)\nconst noDeals: Deal[] = []\n\nconst inDays = (days: number) => new Date(NOW + days * 86_400_000)\n\nconst exampleProps: Kanban2Props = {\n  closedColumns: { lost: 'lost', won: 'won' },\n  columns: [\n    { color: getStageColor(0, 4), id: 'lead', title: 'Lead' },\n    { color: getStageColor(1, 4), id: 'qualified', title: 'Qualified' },\n    { color: getStageColor(2, 4), id: 'proposal', title: 'Proposal' },\n    { color: getStageColor(3, 4), id: 'negotiation', title: 'Negotiation', wipLimit: 4 },\n    { color: 'var(--color-chart-3)', id: 'won', title: 'Won' },\n    { color: 'var(--color-muted-foreground)', id: 'lost', title: 'Lost' },\n  ],\n  deals: [\n    {\n      column: 'lead',\n      description: 'Warehouse analytics',\n      id: 'd1',\n      nextStep: 'Intro call',\n      nextStepAt: inDays(1),\n      owner: 'Maya Patel',\n      title: 'Harbor & Pine',\n      value: 18_000,\n    },\n    {\n      column: 'lead',\n      description: 'Clinic scheduling',\n      id: 'd2',\n      nextStep: 'Reply to inbound form',\n      nextStepAt: inDays(0),\n      owner: 'Luis Romero',\n      title: 'Riverside Dental',\n      value: 7_500,\n    },\n    {\n      column: 'lead',\n      description: 'Franchise reporting',\n      id: 'd3',\n      nextStep: 'Find the ops lead',\n      nextStepAt: inDays(5),\n      owner: 'Aiko Tanaka',\n      title: 'Sunbeam Bakeries',\n      value: 24_000,\n    },\n    {\n      column: 'qualified',\n      description: 'Fleet dashboard, 60 depots',\n      id: 'd4',\n      nextStep: 'Demo for the regional heads',\n      nextStepAt: inDays(2),\n      owner: 'Jonas Weber',\n      title: 'Northwind Logistics',\n      value: 42_000,\n    },\n    {\n      column: 'qualified',\n      description: 'Patient portal pilot',\n      id: 'd5',\n      nextStep: 'Send security questionnaire',\n      nextStepAt: inDays(-2),\n      owner: 'Maya Patel',\n      title: 'Brightline Health',\n      value: 31_200,\n    },\n    {\n      column: 'proposal',\n      description: 'Enterprise plan, 400 seats',\n      id: 'd6',\n      nextStep: 'Walk through pricing with finance',\n      nextStepAt: inDays(1),\n      owner: 'Aiko Tanaka',\n      title: 'Atlas Freight',\n      value: 128_000,\n    },\n    {\n      column: 'proposal',\n      description: 'Data warehouse sync',\n      id: 'd7',\n      nextStep: 'Revise the proposal',\n      nextStepAt: inDays(3),\n      owner: 'Luis Romero',\n      title: 'Meridian Labs',\n      value: 64_500,\n    },\n    {\n      column: 'negotiation',\n      description: 'Multi-region renewal',\n      id: 'd8',\n      nextStep: 'Legal review of the MSA',\n      nextStepAt: inDays(0),\n      owner: 'Jonas Weber',\n      title: 'Vantage Retail',\n      value: 212_000,\n    },\n    {\n      column: 'negotiation',\n      description: 'Claims analytics',\n      id: 'd9',\n      nextStep: 'Agree the discount',\n      nextStepAt: inDays(-1),\n      owner: 'Luis Romero',\n      title: 'Copperleaf Insurance',\n      value: 87_000,\n    },\n    {\n      column: 'won',\n      description: 'Risk reporting suite',\n      id: 'd10',\n      nextStep: 'Kickoff with onboarding',\n      nextStepAt: inDays(2),\n      owner: 'Maya Patel',\n      title: 'Kestrel Bank',\n      value: 96_000,\n    },\n    {\n      column: 'lost',\n      description: 'Booking insights',\n      id: 'd11',\n      nextStep: 'Check in next quarter',\n      nextStepAt: inDays(84),\n      owner: 'Aiko Tanaka',\n      title: 'Halcyon Travel',\n      value: 54_000,\n    },\n  ],\n  now: new Date(NOW),\n  title: 'Deals',\n}\n\nfunction sumValue(deals: Deal[]) {\n  return deals.reduce((sum, deal) => sum + deal.value, 0)\n}\n\nconst Kanban2 = (props: Kanban2Props) => {\n  const {\n    closedColumns,\n    columns,\n    deals: loadedDeals = noDeals,\n    now,\n    onMove,\n    errorMessage,\n    status,\n    title,\n  } = props\n  const [moves, setMoves] = useState<{ column: string; id: string; index: number }[]>([])\n  const deals = useMemo(\n    () =>\n      moves.reduce(\n        (current, move) => moveItem(current, move.id, move.column, move.index),\n        loadedDeals,\n      ),\n    [loadedDeals, moves],\n  )\n  const state = getBlockState(status, loadedDeals)\n  const [collapsed, setCollapsed] = useState<string[]>([closedColumns.lost])\n  const closed = [closedColumns.won, closedColumns.lost]\n  const open = deals.filter((deal) => !closed.includes(deal.column))\n  const won = getColumnItems(deals, closedColumns.won)\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={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          <BlockReady className='text-sm'>\n            <p className='text-muted-foreground text-sm' aria-live='polite'>\n              {open.length} open {open.length === 1 ? 'deal' : 'deals'} worth{' '}\n              {formatCurrency(sumValue(open), { compact: true })}, and{' '}\n              {formatCurrency(sumValue(won), { compact: true })} won.\n            </p>\n          </BlockReady>\n        </header>\n        {(state === 'empty' || state === 'error') && (\n          <BlockStateRows className='border-t pt-3' />\n        )}\n        {(state === undefined || state === 'loading') && (\n          <KanbanBoard\n            className='pb-2'\n            columns={columns}\n            itemName={{ one: 'deal', other: 'deals' }}\n            items={deals}\n            label={`${title} board`}\n            onMove={(id, column, index) => {\n              setMoves((current) => [...current, { column, id, index }])\n              onMove?.(id, column, index)\n            }}\n          >\n            {columns.map((column) => {\n              const columnDeals = getColumnItems(deals, column.id)\n              const isClosed = closed.includes(column.id)\n              return (\n                <KanbanColumn\n                  key={column.id}\n                  collapsed={collapsed.includes(column.id)}\n                  column={column}\n                  onCollapsedChange={\n                    isClosed\n                      ? (value) =>\n                          setCollapsed((current) =>\n                            value\n                              ? [...current, column.id]\n                              : current.filter((other) => other !== column.id),\n                          )\n                      : undefined\n                  }\n                  summary={\n                    <>\n                      <span className='sr-only'>Total </span>\n                      {formatCurrency(sumValue(columnDeals), { compact: true })}\n                    </>\n                  }\n                >\n                  {columnDeals.map((deal) => (\n                    <KanbanCard key={deal.id} item={deal}>\n                      <div className='flex items-start gap-2'>\n                        <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n                          <KanbanCardTitle />\n                          <p className='text-muted-foreground truncate text-xs'>\n                            {deal.description}\n                          </p>\n                        </div>\n                        <KanbanCardMenu className='-my-1 -mr-1' />\n                      </div>\n                      <div className='flex items-center gap-2'>\n                        <span className='font-medium tabular-nums'>\n                          {formatCurrency(deal.value)}\n                        </span>\n                        <KanbanAssignees className='ml-auto' names={[deal.owner]} />\n                      </div>\n                      {!isClosed && (\n                        <div className='flex flex-wrap items-baseline gap-x-2 gap-y-0.5 border-t pt-2.5 text-xs'>\n                          <p className='min-w-0 flex-1 basis-32'>\n                            <span className='text-muted-foreground'>Next: </span>\n                            {deal.nextStep}\n                          </p>\n                          <KanbanDueDate\n                            className='ml-auto shrink-0'\n                            date={deal.nextStepAt}\n                            now={now}\n                          />\n                        </div>\n                      )}\n                    </KanbanCard>\n                  ))}\n                </KanbanColumn>\n              )\n            })}\n          </KanbanBoard>\n        )}\n      </section>\n    </BlockStateProvider>\n  )\n}\n\nexport { Kanban2, exampleProps as kanban2ExampleProps, type Kanban2Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/kanban/kanban-02.tsx"
    }
  ],
  "meta": {
    "shows": "A sales board of deals in columns, each column showing its total value and each deal its next step.",
    "size": "full",
    "usedWith": [
      "pipeline-01",
      "funnel-01"
    ],
    "component": "Kanban2",
    "props": "{ closedColumns: { lost: string; won: string }; columns: { color?: string; icon?: ReactNode; id: string; title: string; wipLimit?: number }[]; deals?: { description: string; nextStep: string; nextStepAt: Date; owner: string; value: number; column: string; id: string; title: string }[]; now: Date; onMove?: (id: string, column: string, index: number) => void; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
