{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "template-board",
  "type": "registry:block",
  "title": "Board app template",
  "description": "The board template: a whole kanban surface from one BoardData. The page draws; your app owns the data. Pass `data`, and `onMove` to save a move to your source (the board shows nothing as moved until your data says so). Without `onMove` the page keeps moves itself, so the mock works as is. Loading and error states take one prop each.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/board.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/skeleton.json",
    "https://ui.klarhimmel.com/r/theme.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/templates/board/board-data.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/templates/board/board-data.ts",
      "content": "// The board template's data shape (KB-218, Felix 2026-11-12: a surface ships \"with its data shape and mock data, so an agent only\n// connects data and never invents a schema\"). Modelled on Klar Sessions' own board: columns in order, cards in a column, a person, a\n// date and one quiet line per card. Fill a BoardData from your source (an API, a database, a JSON file) and pass it to BoardPage;\n// add a field here, not a second type, when your source has more.\n//\n// Saving moves from your own record type: map once, keep the records in state, and let BoardPage tell you when a card moved.\n//   const toBoard = (jobs: Job[]): BoardData => ({ title: 'Jobs', columns: STATUSES.map((s) => ({ id: s, title: s })),\n//     cards: jobs.map((j) => ({ id: j.id, title: j.name, column: j.status, assignee: j.owner, due: j.start /* ISO */, line: j.note })) });\n//   const [jobs, setJobs] = useState<Job[]>([]);                      // load with your own list() call\n//   <BoardPage data={toBoard(jobs)} onMove={async (id, to) => setJobs(await update(id, { status: to }))} />\n// With onMove the page shows a move only once your data says so, so save first, then set the new records. A source field with no\n// slot here (a quote amount) goes into `line` or `status` (\"Quote 42 000 kr\"), never dropped.\n\n/** A column's colour: the status tones every Klarhimmel board shares (to do, in progress, waiting for someone, done). */\nexport type BoardTone = 'todo' | 'doing' | 'review' | 'done';\n\nexport interface BoardColumnData {\n  /** Stable key; cards point at it with `column`. */\n  id: string;\n  title: string;\n  tone?: BoardTone;\n  /** What the column says while it is empty (\"Finished work lands here.\"). */\n  emptyLine?: string;\n}\n\nexport interface BoardCardData {\n  id: string;\n  title: string;\n  /** The id of the column it sits in. */\n  column: string;\n  /** A short number or key people use to name the card (\"12\", \"KB-218\"). */\n  number?: string | number;\n  /** Who it is with. */\n  assignee?: string;\n  /** Due date as an ISO date (YYYY-MM-DD); shown as \"Fri 20 Nov\", with \"Overdue\" beside it once it has passed. */\n  due?: string;\n  /** One quiet sentence under the title (\"Waiting for the florist's quote\"). */\n  line?: string;\n  /** A short label in the card's pill, for example \"Blocked\". Without it the pill shows the column's title. */\n  status?: string;\n}\n\nexport interface BoardData {\n  title: string;\n  description?: string;\n  columns: BoardColumnData[];\n  /** Cards in the order they show within their column. */\n  cards: BoardCardData[];\n}\n\n/** Checks a BoardData read from outside (a JSON file, an API): every card's column exists and every id is unique. Returns the problems, [] when fine. */\nexport function boardProblems(data: BoardData): string[] {\n  const out: string[] = [];\n  const cols = new Set<string>();\n  for (const c of data.columns) { if (cols.has(c.id)) out.push(`column id \"${c.id}\" is used twice`); cols.add(c.id); }\n  const cards = new Set<string>();\n  for (const c of data.cards) {\n    if (cards.has(c.id)) out.push(`card id \"${c.id}\" is used twice`);\n    cards.add(c.id);\n    if (!cols.has(c.column)) out.push(`card \"${c.id}\" points at a missing column \"${c.column}\"`);\n    if (c.due && !/^\\d{4}-\\d{2}-\\d{2}$/.test(c.due)) out.push(`card \"${c.id}\" has a due date that is not YYYY-MM-DD`);\n  }\n  return out;\n}\n\n/** Moves a card to another column, last in it; returns a new BoardData (the page's default when the host keeps the data itself). */\nexport function moveCard(data: BoardData, cardId: string, to: string): BoardData {\n  const card = data.cards.find((c) => c.id === cardId);\n  if (!card || !data.columns.some((c) => c.id === to)) return data;\n  return { ...data, cards: [...data.cards.filter((c) => c.id !== cardId), { ...card, column: to }] };\n}\n\n/** \"Fri 20 Nov\" from \"2026-11-20\"; dates are read in the visitor's own calendar day, never shifted by time zone. */\nexport function dueText(iso: string, locale = 'en-GB'): string {\n  const [y, m, d] = iso.split('-').map(Number);\n  return new Date(y!, m! - 1, d!).toLocaleDateString(locale, { weekday: 'short', day: 'numeric', month: 'short' });\n}\nexport function isOverdue(iso: string, today = new Date()): boolean {\n  const [y, m, d] = iso.split('-').map(Number);\n  return new Date(y!, m! - 1, d!) < new Date(today.getFullYear(), today.getMonth(), today.getDate());\n}\n"
    },
    {
      "path": "src/templates/board/board-mock.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/templates/board/board-mock.ts",
      "content": "// Mock data in the board's shape (KB-218): a small bakery's week, so the page shows every part (four tones, people, dates past and\n// coming, a quiet line, a status pill, an empty column). Replace it with your own BoardData; the page needs nothing else.\nimport type { BoardData } from './board-data';\n\nexport const BOARD_MOCK: BoardData = {\n  title: 'This week at the bakery',\n  description: 'Orders, the shop and the website. Move a card when it changes hands.',\n  columns: [\n    { id: 'todo', title: 'Up next', tone: 'todo', emptyLine: 'New work waits here.' },\n    { id: 'doing', title: 'In progress', tone: 'doing', emptyLine: 'Work being done shows here.' },\n    { id: 'review', title: 'Needs your OK', tone: 'review', emptyLine: 'Work waiting for a yes shows here.' },\n    { id: 'done', title: 'Done', tone: 'done', emptyLine: 'Finished work lands here.' },\n  ],\n  cards: [\n    { id: 'c1', number: 14, title: 'Confirm the wedding cake order for Saturday', column: 'todo', assignee: 'Maja', due: '2026-11-14', line: 'Waiting for the couple to pick a filling.' },\n    { id: 'c2', number: 15, title: 'Order rye flour for December', column: 'todo', assignee: 'Oskar', due: '2026-11-20' },\n    { id: 'c3', number: 11, title: 'Photograph the new cardamom buns', column: 'doing', assignee: 'Ida', status: 'Blocked', line: 'The studio light is out until Friday.' },\n    { id: 'c4', number: 12, title: 'Update the Christmas opening hours on the site', column: 'review', assignee: 'Maja', due: '2026-11-18' },\n    { id: 'c5', number: 9, title: 'Renew the market stall permit', column: 'done', assignee: 'Oskar' },\n  ],\n};\n"
    },
    {
      "path": "src/templates/board/board-page.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/templates/board/board-page.tsx",
      "content": "// The board template (KB-218): a whole kanban surface from one BoardData. The page draws; your app owns the data. Pass `data`, and\n// `onMove` to save a move to your source (the board shows nothing as moved until your data says so). Without `onMove` the page keeps\n// moves itself, so the mock works as is. Loading and error states take one prop each.\nimport { useState } from 'react';\nimport { AlertCircle, Clock } from 'lucide-react';\nimport { Board } from '../../ui/board';\nimport { Button } from '../../ui/button';\nimport { Skeleton } from '../../ui/skeleton';\nimport { dueText, isOverdue, moveCard, type BoardCardData, type BoardData } from './board-data';\n\nexport interface BoardPageProps {\n  data: BoardData;\n  /** Save a move: card id and the column id it went to. Leave out to keep moves in the page. */\n  onMove?(cardId: string, to: string): void;\n  /** Open a card (a drawer, a page of your own). */\n  onOpen?(card: BoardCardData): void;\n  /** While your data loads: the columns' outline with placeholders. */\n  loading?: boolean;\n  /** A load that failed: one sentence and a retry. */\n  error?: { message: string; retry(): void };\n  /** Today, for overdue dates (tests pass a fixed day). */\n  today?: Date;\n}\n\nexport default function BoardPage({ data, onMove, onOpen, loading, error, today = new Date() }: BoardPageProps) {\n  const [own, setOwn] = useState(data);\n  const shown = onMove ? data : own;\n  const move = (card: BoardCardData, to: string) => (onMove ? onMove(card.id, to) : setOwn((d) => moveCard(d, card.id, to)));\n  return (\n    <main className=\"mx-auto flex min-h-dvh w-full max-w-[90rem] flex-col gap-6 px-4 py-6 @container sm:px-6 sm:py-8\">\n      <header className=\"flex flex-col gap-1\">\n        <h1 className=\"text-kh-title font-semibold text-kh-ink\">{shown.title}</h1>\n        {shown.description && <p className=\"max-w-prose text-kh-body text-kh-muted\">{shown.description}</p>}\n      </header>\n      {error ? (\n        <div role=\"alert\" className=\"flex flex-wrap items-center gap-3 rounded-kh border border-kh-line bg-kh-surface-2 p-4 text-kh-body text-kh-ink\">\n          <AlertCircle aria-hidden className=\"size-5 text-kh-danger\" />\n          <span className=\"min-w-0 flex-1\">{error.message}</span>\n          <Button type=\"button\" variant=\"secondary\" size=\"sm\" onClick={error.retry}>Try again</Button>\n        </div>\n      ) : loading ? (\n        <div aria-busy=\"true\" aria-label=\"Loading the board\" className=\"grid gap-4 @3xl:grid-cols-4\">\n          {shown.columns.map((c) => <div key={c.id} className=\"flex flex-col gap-3\"><Skeleton className=\"h-5 w-24\" /><Skeleton className=\"h-24\" /><Skeleton className=\"h-24\" /></div>)}\n        </div>\n      ) : (\n        <Board<BoardCardData>\n          label={shown.title}\n          columns={shown.columns.map((c) => ({ key: c.id, title: c.title, tone: c.tone, emptyLine: c.emptyLine, items: shown.cards.filter((k) => k.column === c.id) }))}\n          id={(k) => k.id}\n          card={(k, col) => ({\n            title: k.title,\n            name: k.title,\n            number: k.number,\n            person: k.assignee,\n            line: k.line,\n            status: k.status ?? (typeof col.title === 'string' ? col.title : undefined),\n            chip: k.due ? { icon: <Clock aria-hidden className=\"size-3.5\" />, text: dueText(k.due), overdue: isOverdue(k.due, today) && col.tone !== 'done' ? 'Overdue' : undefined } : undefined,\n          })}\n          onMove={move}\n          onOpen={onOpen}\n        />\n      )}\n    </main>\n  );\n}\n"
    }
  ]
}
