{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "legend-list",
  "title": "Legend List",
  "description": "Chart key listing each series' dot, name and figure.",
  "dependencies": [
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "@pestoui/segmented-bar",
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/components/legend-list.tsx",
      "content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { segmentedBarDotVariants, type SegmentedBarTone } from \"@/components/segmented-bar\"\n\n/* A chart key read name-first: the dot, the name at full ink, and the figure\n   beside it. SegmentedBar ships a legend of its own and it reads the other way\n   round — a muted name and a bare value at full ink — which suits a caption\n   under the bar and not a key that carries formatted figures. This is that key.\n\n   The swatch comes from `segmentedBarDotVariants`, the same record that paints\n   the band, so a legend row and the band it names cannot resolve to different\n   tokens. The name is always printed: the colour is never the only key.\n\n   An `items` array rather than compound children: every row is the same four\n   parts, and the two variants lay the figure out differently, so the list\n   decides the row markup instead of asking each caller to repeat it. */\nconst legendListVariants = cva(\"\", {\n  variants: {\n    variant: {\n      /* A loose stack: name left, muted figure pushed right. */\n      plain: \"flex flex-col gap-3.5\",\n      /* Hairline rules between rows, a figure with an optional share under it. */\n      divided: \"divide-y divide-border\",\n    },\n  },\n  defaultVariants: {\n    variant: \"plain\",\n  },\n})\n\nconst legendListItemVariants = cva(\"\", {\n  variants: {\n    variant: {\n      plain: \"flex items-center gap-3 text-body-md leading-tight\",\n      divided: \"flex items-center gap-2.5 py-2.5\",\n    },\n  },\n  defaultVariants: {\n    variant: \"plain\",\n  },\n})\n\ntype LegendListVariant = NonNullable<VariantProps<typeof legendListVariants>[\"variant\"]>\n\ntype LegendListItem = {\n  id: string\n  label: React.ReactNode\n  tone: SegmentedBarTone\n  /** The row's figure — a duration, a count, a formatted amount. */\n  figure: React.ReactNode\n  /** A muted second figure under the first, such as a share. `divided` only. */\n  detail?: React.ReactNode\n}\n\ntype LegendListProps = Omit<React.ComponentProps<\"ul\">, \"children\"> & {\n  items: LegendListItem[]\n  variant?: LegendListVariant\n}\n\nfunction LegendList({\n  items,\n  variant = \"plain\",\n  className,\n  ...props\n}: LegendListProps) {\n  return (\n    <ul\n      data-slot=\"legend-list\"\n      data-variant={variant}\n      className={cn(legendListVariants({ variant }), className)}\n      {...props}\n    >\n      {items.map((item) => (\n        <li\n          key={item.id}\n          data-slot=\"legend-list-item\"\n          className={legendListItemVariants({ variant })}\n        >\n          <span\n            aria-hidden=\"true\"\n            data-slot=\"legend-list-swatch\"\n            className={cn(segmentedBarDotVariants({ tone: item.tone }), \"size-2.5\")}\n          />\n          {variant === \"divided\" ? (\n            <>\n              <span data-slot=\"legend-list-label\" className=\"min-w-0 flex-1 truncate\">\n                {item.label}\n              </span>\n              {/* The wrapper's leading-tight would reach the detail too, so the\n                  detail sets its own line height back to 20px. */}\n              <span className=\"flex flex-col items-end leading-tight\">\n                <span data-slot=\"legend-list-figure\" className=\"tabular-nums\">\n                  {item.figure}\n                </span>\n                {/* null and false are what `cond && node` leaves behind:\n                    nothing to print, so no element. */}\n                {item.detail != null && item.detail !== false ? (\n                  <span\n                    data-slot=\"legend-list-detail\"\n                    className=\"text-body-sm leading-5 text-muted-foreground tabular-nums\"\n                  >\n                    {item.detail}\n                  </span>\n                ) : null}\n              </span>\n            </>\n          ) : (\n            <>\n              <span data-slot=\"legend-list-label\" className=\"min-w-0 truncate\">\n                {item.label}\n              </span>\n              <span\n                data-slot=\"legend-list-figure\"\n                className=\"ml-auto shrink-0 text-muted-foreground tabular-nums\"\n              >\n                {item.figure}\n              </span>\n            </>\n          )}\n        </li>\n      ))}\n    </ul>\n  )\n}\n\nexport { LegendList, legendListVariants, legendListItemVariants }\nexport type { LegendListProps, LegendListItem, LegendListVariant }\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}