{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-onboarding-checklist",
  "type": "registry:block",
  "title": "App, setup checklist",
  "description": "A getting-started checklist with a progress bar and a count that follow the checkboxes. Each step has a title, a line of help and maybe one action. A completion message appears above the list when all are done; the list stays so a step can be unticked.",
  "categories": [
    "app"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/checkbox.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-app.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/app-onboarding-checklist/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-onboarding-checklist/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60).optional(),\n  title: t(120),\n  description: t(300).optional(),\n  /** The progress line is built as \"2 of 4 steps done\": the count, `of`, the total and `suffix`. */\n  progress: z.object({ label: req(40), of: t(10), suffix: t(30) }),\n  items: z\n    .array(z.object({ title: req(80), description: t(160), done: z.boolean(), action: t(30).optional() }))\n    .min(2)\n    .max(7),\n  /** Said above the list when every item is done; the list stays, so a step can be unticked again. */\n  complete: t(120),\n});\n\nexport const spec = defineSpec({\n  type: 'app-onboarding-checklist',\n  aliases: ['app/onboarding-checklist'],\n  name: 'App, setup checklist',\n  category: 'app',\n  role: 'body',\n  description: 'A getting-started checklist with a progress bar and a count that follow the checkboxes. Each step has a title, a line of help and maybe one action. A completion message appears above the list when all are done; the list stays so a step can be unticked.',\n  schema,\n  defaults: {\n    \"eyebrow\": \"Get started\",\n    \"title\": \"Name what is being set up\",\n    \"description\": \"Say how many steps remain until it works and that the list stays open.\",\n    \"progress\": {\n      \"label\": \"Setup progress\",\n      \"of\": \"in\",\n      \"suffix\": \"steps done\"\n    },\n    \"items\": [\n      {\n        \"title\": \"Name the first step\",\n        \"description\": \"Say what the first step needs.\",\n        \"done\": true\n      },\n      {\n        \"title\": \"Name the second step\",\n        \"description\": \"Say what the second step sets.\",\n        \"done\": true,\n        \"action\": \"First action\"\n      },\n      {\n        \"title\": \"Name the third step\",\n        \"description\": \"Say why the third step matters.\",\n        \"done\": false,\n        \"action\": \"Second action\"\n      },\n      {\n        \"title\": \"Name the last step\",\n        \"description\": \"Say how the last step is shared.\",\n        \"done\": false\n      }\n    ],\n    \"complete\": \"Say that everything is set up and what happens now.\"\n  },\n});\n"
    },
    {
      "path": "src/blocks/app-onboarding-checklist/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-onboarding-checklist/index.tsx",
      "content": "import { useId } from 'react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { cn } from '../../lib/utils';\nimport { Button } from '../../ui/button';\nimport { Checkbox } from '../../ui/checkbox';\nimport { Container, Section, SectionHeader, useEditing, useNamed } from '../_shared/kit';\nimport { AppPanel, 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>;\n\nfunction AppOnboardingChecklist({ props }: BlockProps<Props>) {\n  const progressNamed = useNamed(props.progress.label);\n  const id = useId();\n  const editing = useEditing();\n  const [done, setDone] = useSynced(props.items.map((i) => i.done));\n  const count = done.filter(Boolean).length;\n  const total = props.items.length;\n  const all = count === total;\n  return (\n    <Section labelledBy={id}>\n      <Container width=\"narrow\">\n        <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        <AppPanel className=\"mt-10\">\n          <div className=\"flex flex-col gap-3 border-b border-kh-line p-6 @xl:px-8\">\n            <div className=\"flex flex-wrap items-baseline justify-between gap-x-4 text-kh-small\">\n              <label htmlFor={`${id}-p`} className=\"font-medium\">\n                <Text path={['progress', 'label']} value={props.progress.label} as=\"span\" />\n              </label>\n              <p role=\"status\" className=\"tabular-nums text-kh-muted\">\n                {count} <Text path={['progress', 'of']} value={props.progress.of} as=\"span\" /> {total} <Text path={['progress', 'suffix']} value={props.progress.suffix} as=\"span\" />\n              </p>\n            </div>\n            {progressNamed && (\n            <progress\n              id={`${id}-p`}\n              value={count}\n              max={total}\n              className=\"h-2 w-full appearance-none overflow-hidden rounded-kh-pill [&::-moz-progress-bar]:bg-kh-accent [&::-webkit-progress-bar]:bg-kh-surface-3 [&::-webkit-progress-value]:bg-kh-accent\"\n            />\n            )}\n          </div>\n          <StateSlot show={all} className=\"border-b border-kh-line px-6 py-4 text-kh-body @xl:px-8\">\n            <p role=\"status\">\n              <Text path={['complete']} value={props.complete} as=\"span\" />\n            </p>\n          </StateSlot>\n          <ul className=\"divide-y divide-kh-line px-6 @xl:px-8\">\n            {props.items.map((it, i) => (\n              <li key={i} className=\"flex flex-col gap-1 py-2 @xl:flex-row @xl:items-center @xl:justify-between @xl:gap-6\">\n                <Checkbox\n                  checked={done[i]}\n                  onCheckedChange={(c) => setDone((d) => d.map((x, k) => (k === i ? c === true : x)))}\n                  label={<Text path={['items', i, 'title']} value={it.title} as=\"span\" className={cn(done[i] && 'text-kh-muted line-through')} />}\n                  hint={<Text path={['items', i, 'description']} value={it.description} as=\"span\" />}\n                />\n                {it.action && (\n                  <div hidden={done[i] && !editing} className=\"self-start @xl:shrink-0\">\n                    <Button variant=\"secondary\">\n                      <Text path={['items', i, 'action']} value={it.action} as=\"span\" />\n                    </Button>\n                  </div>\n                )}\n              </li>\n            ))}\n          </ul>\n        </AppPanel>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(AppOnboardingChecklist);\n"
    }
  ]
}
