{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-boards-kanban",
  "type": "registry:block",
  "title": "App, kanban board",
  "description": "A board of columns with cards (title, assignee, due date, status flag). Every card has a Move menu that lists the other columns, so a card moves by keyboard; the move is announced and focus follows the card. Empty columns say so. Filled, empty, loading and error states.",
  "categories": [
    "app"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/board.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-app.json",
    "https://ui.klarhimmel.com/r/skeleton.json"
  ],
  "files": [
    {
      "path": "src/blocks/app-boards-kanban/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-boards-kanban/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, t } from '../_shared/schema';\n\nconst card = z.object({\n  title: t(80),\n  assignee: t(40),\n  /** The due date as people read it (\"Fri 20 Nov\"). */\n  due: t(20),\n  /** A short flag such as \"Blocked\". Optional. */\n  status: t(20).optional(),\n  /** Past its date: says the overdue word beside the due date, so it is never colour alone. */\n  overdue: z.boolean(),\n});\n\nconst schema = z.object({\n  eyebrow: t(60).optional(),\n  title: t(120),\n  description: t(300).optional(),\n  columns: z.array(z.object({ title: t(30), cards: z.array(card).max(8) })).min(2).max(5),\n  /** Said after the number on a column (\"3 cards\"). */\n  /** The word after a count of one: \"1 card\". */\n  countOne: t(20),\n  countLabel: t(20),\n  /** What an empty column says. */\n  emptyColumn: t(80),\n  /** Each card has a button with this word; its menu lists the other columns. This is the keyboard way to move a card. */\n  moveLabel: t(20),\n  moveTo: t(30),\n  /** The announcement after a move: \"<card> moved to <column>\". */\n  moved: t(30),\n  overdueLabel: t(20),\n  /** filled; empty (nothing on the board yet); loading (placeholders, said once); error (a banner with a retry). */\n  state: z.enum(['filled', 'empty', 'loading', 'error']),\n  messages: z.object({ empty: t(120), loading: t(60), error: t(120), retry: t(30) }),\n});\n\nexport const spec = defineSpec({\n  type: 'app-boards-kanban',\n  aliases: ['app/boards-kanban'],\n  name: 'App, kanban board',\n  category: 'app',\n  role: 'body',\n  description: 'A board of columns with cards (title, assignee, due date, status flag). Every card has a Move menu that lists the other columns, so a card moves by keyboard; the move is announced and focus follows the card. Empty columns say so. Filled, empty, loading and error states.',\n  schema,\n  defaults: {\n    \"eyebrow\": \"Name the section\",\n    \"title\": \"Name the board\",\n    \"description\": \"Say in one line what the work on this board is for.\",\n    \"columns\": [\n      {\n        \"title\": \"To do\",\n        \"cards\": [\n          {\n            \"title\": \"Say what the first task is about\",\n            \"assignee\": \"Assignee\",\n            \"due\": \"Mon 00 Jan\",\n            \"status\": \"Blocked\",\n            \"overdue\": true\n          },\n          {\n            \"title\": \"Say what the second task is about\",\n            \"assignee\": \"Assignee\",\n            \"due\": \"Mon 00 Jan\",\n            \"overdue\": false\n          }\n        ]\n      },\n      {\n        \"title\": \"In progress\",\n        \"cards\": [\n          {\n            \"title\": \"Say what the third task is about\",\n            \"assignee\": \"Assignee\",\n            \"due\": \"Mon 00 Jan\",\n            \"overdue\": false\n          }\n        ]\n      },\n      {\n        \"title\": \"Done\",\n        \"cards\": []\n      }\n    ],\n    \"countOne\": \"card\",\n    \"countLabel\": \"cards\",\n    \"emptyColumn\": \"Say the column is empty.\",\n    \"moveLabel\": \"Move\",\n    \"moveTo\": \"Move to\",\n    \"moved\": \"moved to\",\n    \"overdueLabel\": \"Overdue\",\n    \"state\": \"filled\",\n    \"messages\": {\n      \"empty\": \"Say the board is empty and how to add the first card.\",\n      \"loading\": \"Say the board is loading…\",\n      \"error\": \"Say the board did not load.\",\n      \"retry\": \"Try again\"\n    }\n  },\n});\n"
    },
    {
      "path": "src/blocks/app-boards-kanban/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-boards-kanban/index.tsx",
      "content": "import { useEffect, useId, useRef } from 'react';\nimport { AlertCircle } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Board } from '../../ui/board';\nimport { Button } from '../../ui/button';\nimport { Skeleton } from '../../ui/skeleton';\nimport { Container, Opt, Section, SectionHeader, useEditing } from '../_shared/kit';\nimport { StateSlot, useSynced } from '../_shared/app-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\ntype Card = Props['columns'][number]['cards'][number];\n/** A card with where it came from in the props, so its text keeps its editable path after it has moved. */\ntype Placed = Card & { at: [number, number] };\n\nconst place = (columns: Props['columns']): Placed[][] => columns.map((c, ci) => c.cards.map((card, k) => ({ ...card, at: [ci, k] as [number, number] })));\n\nfunction AppBoardsKanban({ props }: BlockProps<Props>) {\n  const id = useId();\n  const editing = useEditing();\n  // The block is the board's host: moves are kept until the board's own data changes (compared by content, so a parent that rebuilds its\n  // arrays does not wipe them).\n  const [cols, setCols] = useSynced(place(props.columns));\n  const [retried, setRetried] = useSynced(false, props.state);\n  const state = retried && props.state === 'error' ? 'loading' : props.state;\n  const loadingMsg = useRef<HTMLParagraphElement>(null);\n  const justRetried = useRef(false);\n  useEffect(() => {\n    if (justRetried.current) loadingMsg.current?.focus();\n    justRetried.current = false;\n  }, [retried]);\n  const key = (p: Placed) => `${p.at[0]}:${p.at[1]}`;\n  const move = (card: Placed, to: string) => setCols((all) => all.map((list, i) => (String(i) === to ? [...list.filter((c) => c !== card), card] : list.filter((c) => c !== card))));\n  const loading = state === 'loading';\n  const shown = state === 'filled' || editing;\n  const at = (c: Placed, field: string) => ['columns', c.at[0], 'cards', c.at[1], field];\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        <StateSlot show={state === 'empty'} className=\"mt-6\">\n          <p role=\"status\" className=\"text-kh-small text-kh-muted\">\n            <Text path={['messages', 'empty']} value={props.messages.empty} as=\"span\" />\n          </p>\n        </StateSlot>\n        <StateSlot show={loading} className=\"mt-6\">\n          <p ref={loadingMsg} tabIndex={-1} role=\"status\" className=\"text-kh-small text-kh-muted outline-none\">\n            <Text path={['messages', 'loading']} value={props.messages.loading} as=\"span\" />\n          </p>\n        </StateSlot>\n        <StateSlot show={state === 'error'} className=\"mt-6\">\n          <div role=\"alert\" className=\"flex flex-wrap items-center gap-3 rounded-kh-lg border border-kh-danger px-4 py-3 text-kh-small\">\n            <AlertCircle aria-hidden className=\"size-4 text-kh-danger\" />\n            <Text path={['messages', 'error']} value={props.messages.error} as=\"span\" />\n            <Button\n              type=\"button\"\n              variant=\"secondary\"\n              onClick={() => {\n                justRetried.current = true;\n                setRetried(true);\n              }}\n            >\n              <Text path={['messages', 'retry']} value={props.messages.retry} as=\"span\" />\n            </Button>\n          </div>\n        </StateSlot>\n        {editing && (\n          <p className=\"mt-4 text-kh-caption text-kh-muted\">\n            <Text path={['countLabel']} value={props.countLabel} as=\"span\" /> · <Text path={['countOne']} value={props.countOne} as=\"span\" /> · <Text path={['moveLabel']} value={props.moveLabel} as=\"span\" /> · <Text path={['moveTo']} value={props.moveTo} as=\"span\" /> · <Text path={['moved']} value={props.moved} as=\"span\" /> · <Text path={['overdueLabel']} value={props.overdueLabel} as=\"span\" /> · <Text path={['emptyColumn']} value={props.emptyColumn} as=\"span\" />\n          </p>\n        )}\n        {loading ? (\n          <div aria-busy className=\"mt-8 grid gap-(--kh-shell-gap) @3xl:grid-cols-[repeat(auto-fit,minmax(15rem,1fr))]\">\n            {props.columns.map((col, ci) => (\n              <div key={ci} aria-hidden className=\"flex flex-col gap-2 rounded-(--kh-panel-radius) bg-(--kh-panel-bg) p-1.5 shadow-(--kh-panel-shadow)\">\n                <p className=\"px-2.5 py-2.5 text-kh-small font-medium\">{col.title}</p>\n                <div className=\"flex flex-col gap-2 rounded-(--kh-well-radius) bg-(--kh-well) p-2\"><Skeleton className=\"h-24 w-full\" /><Skeleton className=\"h-24 w-full\" /></div>\n              </div>\n            ))}\n          </div>\n        ) : shown && (\n          <Board<Placed>\n            className=\"mt-8\"\n            label={props.title}\n            columns={props.columns.map((col, ci) => ({ key: String(ci), title: <Text path={['columns', ci, 'title']} value={col.title} as=\"span\" />, name: col.title, items: cols[ci] ?? [] }))}\n            id={key}\n            card={(c) => ({\n              title: <Text path={at(c, 'title')} value={c.title} as=\"span\" />,\n              name: c.title,\n              person: <Text path={at(c, 'assignee')} value={c.assignee} as=\"span\" />,\n              avatar: c.assignee,\n              status: c.status || editing ? <Opt path={at(c, 'status')} value={c.status} as=\"span\" placeholder=\"Status\" /> : undefined,\n              chip: { text: <Text path={at(c, 'due')} value={c.due} as=\"span\" />, overdue: c.overdue ? props.overdueLabel : undefined },\n            })}\n            onMove={move}\n            words={{ column: props.title, moveTo: props.moveTo, moved: props.moved, more: props.moveLabel, empty: props.emptyColumn, count: (n) => `${n} ${n === 1 ? props.countOne : props.countLabel}` }}\n          />\n        )}\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(AppBoardsKanban);\n"
    }
  ]
}
