{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bar-chart",
  "type": "registry:item",
  "title": "Bar Chart",
  "description": "Values compared side by side as horizontal bars, longest-to-shortest if `sorted`. Each bar has its label and value in text, and the chart is a list screen readers read in order, so nothing depends on seeing the bars. `items` is `[{ label, value }]`; `unit` goes after each value (\"%\", \" visits\"). `max` sets the full length (defaults to the largest value).",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "data"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/bar-chart.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/bar-chart.js",
      "content": "// Generated by zubra from bar-chart.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"bar-chart\";\n\nexport default $define(tag, {\n  props: {\n    \"items\": { attribute: \"items\", default: [], required: false },\n    \"label\": { attribute: \"label\", default: \"\", required: false },\n    \"unit\": { attribute: \"unit\", default: \"\", required: false },\n    \"max\": { attribute: \"max\", default: 0, required: false },\n    \"sorted\": { attribute: \"sorted\", default: false, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (bar-chart) to ([data-zb-slotted=\\\"bar-chart\\\"]) {\\n  :scope { display: block; }\\n  figure { margin: 0; }\\n  figcaption { margin-bottom: 0.75rem; font-weight: 700; }\\n  ol { display: grid; gap: 0.55rem; margin: 0; padding: 0; list-style: none; }\\n  li { display: grid; grid-template-columns: minmax(5rem, 30%) 1fr auto; align-items: center; gap: 0.75rem; font-size: 0.9rem; }\\n  .bars-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\\n  .bars-track { height: 0.85rem; border-radius: calc(var(--radius, 0.625rem) * 0.3); background: color-mix(in oklab, var(--muted, #f4f4f5) 70%, transparent); overflow: hidden; }\\n  .bars-fill { display: block; height: 100%; border-radius: inherit; background: var(--chart-1, oklch(0.65 0.2 40)); transition: width var(--duration-slow, 400ms) var(--ease-out, ease-out); }\\n  .bars-value { min-width: 3.5rem; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n}\\n}\\n\",\n  template: \"\\n  <figure>\\n    <!--[--><!--]-->\\n    <ol>\\n      <!--[--><!--]-->\\n    </ol>\\n  </figure>\\n\",\n  setup($p, $emit) {\n  const list = __zubraComputed(() => ($p.sorted ? $p.items.toSorted((a, b) => b.value - a.value) : $p.items))\n  const top = __zubraComputed(() => ($p.max > 0 ? $p.max : Math.max(1, ...$p.items.map((item) => item.value))))\n  // en-US grouping and up to three decimals, as toLocaleString(\"en-US\") gives, in arithmetic the\n  // server runs too (toLocaleString is the browser's alone), so the server's HTML has the numbers.\n  const thousands = (n) => (n < 1000 ? String(n) : `${thousands(Math.floor(n / 1000))},${String(n % 1000).padStart(3, \"0\")}`)\n  const number = (value) => {\n    const milli = Math.round(Math.abs(value) * 1000)\n    const rest = milli % 1000\n    const fraction = rest === 0 ? \"\" : rest % 100 === 0 ? `.${rest / 100}` : rest % 10 === 0 ? `.${String(rest / 10).padStart(2, \"0\")}` : `.${String(rest).padStart(3, \"0\")}`\n    return `${value < 0 && milli > 0 ? \"-\" : \"\"}${thousands(Math.floor(milli / 1000))}${fraction}`\n  }\n  const format = (value) => `${typeof value === \"number\" ? number(value) : value}${$p.unit}`\n    return [\n      { path: [0, 0], when: () => $p.label, blocks: [{ template: \"<figcaption></figcaption>\", parts: () => [{ path: [0], text: () => $t($p.label) }] }, null] },\n      { path: [0, 1], attribute: \"aria-label\", value: () => ($p.label || null) },\n      { path: [0, 1, 0], each: () => $r(list), key: (item, $index) => $r(item).label, block: { template: \"\\n        <li>\\n          <span class=\\\"bars-label\\\"></span>\\n          <span class=\\\"bars-track\\\" aria-hidden=\\\"true\\\"><span class=\\\"bars-fill\\\"></span></span>\\n          <span class=\\\"bars-value\\\"></span>\\n        </li>\\n      \", parts: (item, $index) => [{ path: [0, 0], text: () => $t($r(item).label) }, { path: [0, 1, 0], style: \"width\", value: () => (`${Math.max(0, Math.min(100, ($r(item).value / top.get()) * 100))}%`) }, { path: [0, 2], text: () => $t((format($r(item).value))) }] } },\n    ];\n  },\n});\n"
    }
  ]
}
