{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bar-list",
  "title": "BarList",
  "description": "A ranking: a name, a bar and a value on every row.",
  "registryDependencies": [
    "https://creance.pages.dev/r/creance-base.json",
    "https://creance.pages.dev/r/creance-chart.json"
  ],
  "files": [
    {
      "path": "bar-list/BarList.css",
      "content": ".cr-bar-list {\n  padding: 0;\n  list-style: none;\n}\n\n.cr-bar-list__item {\n  display: flex;\n  flex-direction: column;\n  gap: 6px;\n}\n\n.cr-bar-list__head {\n  display: flex;\n  justify-content: space-between;\n  gap: var(--cr-space-3);\n  font-size: var(--cr-font-size-sm);\n}\n\n.cr-bar-list__label {\n  font-weight: var(--cr-font-weight-semibold);\n}\n\n.cr-bar-list__value {\n  color: var(--cr-color-text-secondary);\n}\n\n.cr-bar-list__track {\n  height: 8px;\n  overflow: hidden;\n  border-radius: var(--cr-radius-full);\n  background: var(--cr-color-bg-subtle);\n}\n\n.cr-bar-list__bar {\n  display: block;\n  height: 100%;\n  border-radius: var(--cr-radius-full);\n  background: var(--cr-chart-2);\n}\n\n.cr-bar-list__item[data-top] .cr-bar-list__bar {\n  background: var(--cr-chart-1);\n}\n",
      "type": "registry:file",
      "target": "@components/creance/bar-list/BarList.css"
    },
    {
      "path": "bar-list/BarList.tsx",
      "content": "import type { ReactNode } from 'react';\nimport { formatter, type ValueFormat } from '@/lib/creance/chart';\nimport { cx } from '@/lib/creance/cx';\nimport './BarList.css';\n\nexport interface BarListItem {\n  label: ReactNode;\n  value: number;\n}\n\nexport interface BarListProps extends ValueFormat {\n  /** Shown in the order given. Sort them yourself, largest first, for a ranking. */\n  items: BarListItem[];\n  /** Accessible name of the list: \"Tokens by agent\". */\n  label: string;\n  className?: string;\n}\n\n/** A ranking: a name, a bar and a value on every row. The longest bar is ink. */\nexport function BarList({ items, label, className, ...format }: BarListProps) {\n  const fmt = formatter(format);\n  const max = Math.max(...items.map((i) => i.value), 0) || 1;\n  return (\n    <ul className={cx('cr-chart cr-bar-list', className)} aria-label={label}>\n      {items.map((item, i) => (\n        <li key={i} className=\"cr-bar-list__item\" data-top={item.value === max || undefined}>\n          <span className=\"cr-bar-list__head\">\n            <span className=\"cr-bar-list__label\">{item.label}</span>\n            <span className=\"cr-bar-list__value\">{fmt(item.value)}</span>\n          </span>\n          <span className=\"cr-bar-list__track\" aria-hidden=\"true\">\n            <span className=\"cr-bar-list__bar\" style={{ width: `${(Math.max(item.value, 0) / max) * 100}%` }} />\n          </span>\n        </li>\n      ))}\n    </ul>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/creance/bar-list/BarList.tsx"
    }
  ],
  "categories": [
    "molecule",
    "charts"
  ],
  "type": "registry:ui"
}