{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-bars",
  "type": "registry:block",
  "title": "Stats, bars",
  "description": "Two to six measures as labelled horizontal bars with the value at the end. The bar length is the number in `value` (0 to 100, any step: 4% draws 4%; the old `fill` prop is ignored); use it for shares and rates, not for raw counts. A value with no number draws no bar.",
  "categories": [
    "stats"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-app.json",
    "https://ui.klarhimmel.com/r/kit-c-proof.json"
  ],
  "files": [
    {
      "path": "src/blocks/stats-bars/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-bars/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  items: z.array(z.object({\n    label: req(60),\n    /** The number the bar shows, written as text: \"62%\" or \"4,5 %\". Its first number (0 to 100) is the bar length and the meter value. */\n    value: t(20),\n    note: t(100),\n  })).min(2).max(6),\n});\n\nexport const spec = defineSpec({\n  type: 'stats-bars',\n  aliases: ['stats/bars'],\n  name: 'Stats, bars',\n  category: 'stats',\n  role: 'body',\n  description: 'Two to six measures as labelled horizontal bars with the value at the end. The bar length is the number in `value` (0 to 100, any step: 4% draws 4%; the old `fill` prop is ignored); use it for shares and rates, not for raw counts. A value with no number draws no bar.',\n  schema,\n  defaults: {\n    eyebrow: 'Name the section',\n    title: 'Say what the shares divide',\n    description: 'Say what the shares are of and across how many.',\n    items: [\n      { label: 'Name the first share', value: '00%', note: 'Say how it changed.' },\n      { label: 'Name the second share', value: '00%', note: 'Say how it changed.' },\n      { label: 'Name the third share', value: '00%', note: 'Say who it is mostly made up of.' },\n      { label: 'Name the last', value: '00%', note: '' },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/stats-bars/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-bars/index.tsx",
      "content": "import { Text, withHeadingLevel } from '../../editing';\nimport { Container, Opt, Section } from '../_shared/kit';\nimport { Heading, useHeadingId } from '../_shared/c-proof-kit';\nimport { parseAmount } 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\n/** The bar length in percent from the number in `value`, clamped to 0 to 100; null when the text has no number. */\nconst percentOf = (value: string) => {\n  const n = parseAmount(value);\n  return n === null ? null : Math.min(100, Math.max(0, n));\n};\n\nfunction StatsBars({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        <Heading id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        <ul className=\"mt-14 max-w-4xl space-y-8\">\n          {props.items.map((item, i) => {\n            const pct = percentOf(item.value);\n            return (\n            <li key={i}>\n              <div className=\"flex items-baseline justify-between gap-6\">\n                <Text path={['items', i, 'label']} value={item.label} as=\"span\" className=\"text-kh-body font-medium\" />\n                <Text path={['items', i, 'value']} value={item.value} as=\"span\" className=\"text-kh-heading font-semibold tabular-nums\" />\n              </div>\n              {pct !== null && (\n                <div role=\"meter\" aria-label={item.label} aria-valuemin={0} aria-valuemax={100} aria-valuenow={pct} aria-valuetext={item.value} className=\"mt-3 h-3 overflow-hidden rounded-kh-pill bg-kh-surface-2\">\n                  <svg aria-hidden width=\"100%\" height=\"100%\" className=\"block\">\n                    <rect width={`${pct}%`} height=\"100%\" rx=\"6\" className=\"fill-kh-accent\" />\n                  </svg>\n                </div>\n              )}\n              <Opt path={['items', i, 'note']} value={item.note} className=\"mt-2 text-kh-small text-kh-muted\" placeholder=\"Note\" />\n            </li>\n            );\n          })}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(StatsBars);\n"
    }
  ]
}
