{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rank-list",
  "title": "Rank List",
  "description": "Ordered ranking with a leading identity slot, a muted second line and a trailing figure.",
  "dependencies": [
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/components/rank-list.tsx",
      "content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* ---------------------------------------------------------------------------\n   Ranked list — \"1 · 🇦🇺 · Australia · ……… · 40%\". Top locations, top customers\n   by spend, top referrers: the shape a dashboard reaches for when a <Table>\n   would be four columns of chrome wrapped around two facts.\n\n   Compound rather than a `rows={[…]}` prop, for one reason: `media` is the slot\n   that makes this component worth having — a flag, an <Avatar>, a chart-token\n   dot — and a data prop would push every one of those through a render\n   callback. Nothing here holds state; the caller arrives already sorted.\n--------------------------------------------------------------------------- */\n\n/* Density moves layout, not type — the same rule `tableDensity` follows. A list\n   that shrinks its own text stops matching the card it sits in, so `sm` buys\n   rows and nothing else. The parts read these back with the `default` values as\n   var() fallbacks, so a row composed outside a <RankList> still renders. */\nconst rankListDensity = {\n  default:\n    \"[--rank-gap:--spacing(3)] [--rank-py:--spacing(2)] [--rank-ordinal:--spacing(5)] [--rank-media:--spacing(5)]\",\n  sm: \"[--rank-gap:--spacing(2.5)] [--rank-py:--spacing(1)] [--rank-ordinal:--spacing(4)] [--rank-media:--spacing(4)]\",\n} as const\n\nconst rankListVariants = cva(\"group/rank-list flex w-full min-w-0 flex-col text-sm\", {\n  variants: {\n    size: rankListDensity,\n    /* `none` hides the ordinal from the root rather than from the row, so an\n       item never has to know which mode it is in — one prop flips the whole\n       list, and a hand-composed row inherits the decision for free. Hiding it\n       with display:none drops it from the accessibility tree too, which is the\n       intent: in this mode the media carries identity and the <ol> still\n       reports position. */\n    numbering: {\n      ordinal: \"\",\n      none: \"[&_[data-slot=rank-list-ordinal]]:hidden\",\n    },\n  },\n  defaultVariants: {\n    size: \"default\",\n    numbering: \"ordinal\",\n  },\n})\n\ntype RankListProps = React.ComponentProps<\"ol\"> & VariantProps<typeof rankListVariants>\n\n/* An <ol> in both numbering modes. `numbering` decides whether the ordinal is\n   *drawn*, not whether the data is ordered — a top-customers list carrying\n   avatars instead of numbers is still a ranking, and a <ul> would tell a screen\n   reader otherwise. The `data-*` pair is emitted for descendants and for tests;\n   the styling above is computed from the cva, never read back off the root. */\nfunction RankList({\n  className,\n  size = \"default\",\n  numbering = \"ordinal\",\n  ...props\n}: RankListProps) {\n  return (\n    <ol\n      data-slot=\"rank-list\"\n      data-size={size}\n      data-numbering={numbering}\n      /* Preflight strips list-style, which drops list semantics in Safari —\n         restore them explicitly, same as the activity feed does. */\n      role=\"list\"\n      className={cn(rankListVariants({ size, numbering }), className)}\n      {...props}\n    />\n  )\n}\n\n/* `value` is deliberately taken away from <li>: the element already owns a\n   numeric `value` attribute — its ordinal — so letting the trailing figure land\n   on it would type-check and then quietly renumber the list. The figure keeps\n   the readable name and `rank` is what feeds the attribute. */\ntype RankListItemProps = Omit<React.ComponentProps<\"li\">, \"value\"> & {\n  /** Position in the ranking. Also feeds the <li> `value` attribute, so a list\n   *  showing the top five of a longer ranking still reports true positions. */\n  rank?: number\n  /** Leading identity slot — a flag, an <Avatar>, a `bg-chart-*` dot. */\n  media?: React.ReactNode\n  label: React.ReactNode\n  /** Muted second line — an email under a name, a region under a country. */\n  sublabel?: React.ReactNode\n  /** Trailing figure. Tabular, so a column of them lines up on the decimal. */\n  value?: React.ReactNode\n  /** 0–1, normally `value / max`. Paints a proportional wash behind the row.\n   *  A redundant reading of `value`, never information of its own — the wash is\n   *  aria-hidden, so anything it alone would say is lost. */\n  bar?: number\n}\n\nfunction RankListItem({\n  rank,\n  media,\n  label,\n  sublabel,\n  value,\n  bar,\n  className,\n  ...props\n}: RankListItemProps) {\n  /* Clamped rather than trusted. `bar` is almost always `value / max` computed\n     by the caller, and a single stale max sends the wash past the row's edge. */\n  const fill =\n    typeof bar === \"number\" && Number.isFinite(bar) ? Math.min(1, Math.max(0, bar)) : 0\n\n  return (\n    <li\n      data-slot=\"rank-list-item\"\n      value={rank}\n      className={cn(\n        \"relative flex items-center gap-[var(--rank-gap,calc(var(--spacing)*3))] px-2 py-[var(--rank-py,calc(var(--spacing)*2))]\",\n        className\n      )}\n      {...props}\n    >\n      {fill > 0 ? (\n        <span\n          data-slot=\"rank-list-bar\"\n          /* Hidden from assistive tech because the `value` beside it already\n             states the figure in words — a label here would only repeat it.\n           *\n           * It lands *under* the row by tree order rather than by a z-index: an\n           * absolutely positioned box outranks in-flow content at the same\n           * stacking level, so each sibling below carries `relative` and DOM\n           * order settles the paint. The row stays out of the z-index contract.\n           *\n           * Rounded on the trailing edge only. This box grows, which is exactly\n           * where the radius rule bites — a 3% row rounded on all four corners\n           * collapses into a lozenge. Keeping the leading edge flat against the\n           * row's start also reads as a fill rather than as a row highlight. */\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-y-0 left-0 rounded-r-sm bg-secondary transition-[width] duration-spring-glide ease-spring-glide\"\n          style={{ width: `${fill * 100}%` }}\n        />\n      ) : null}\n\n      <span\n        data-slot=\"rank-list-ordinal\"\n        /* tabular-nums is what puts 1, 10 and 100 on one digit grid. The width\n           is a floor rather than a fix: it reserves the single-digit case so a\n           top-five list is not tighter than a top-twenty one, and three digits\n           widen the column instead of clipping inside it. */\n        className=\"relative min-w-[var(--rank-ordinal,calc(var(--spacing)*5))] shrink-0 text-right tabular-nums text-muted-foreground\"\n      >\n        {rank}\n      </span>\n\n      {media != null ? (\n        <span\n          data-slot=\"rank-list-media\"\n          /* The label names the row, so an announced flag reads \"flag:\n             Australia, Australia\". Anything in this slot that the label does not\n             already say belongs in the label instead. */\n          aria-hidden=\"true\"\n          className=\"relative flex size-[var(--rank-media,calc(var(--spacing)*5))] shrink-0 items-center justify-center *:data-[slot=avatar]:size-full\"\n        >\n          {media}\n        </span>\n      ) : null}\n\n      <span data-slot=\"rank-list-text\" className=\"relative flex min-w-0 flex-1 flex-col\">\n        <span\n          data-slot=\"rank-list-label\"\n          className=\"truncate font-medium text-foreground\"\n        >\n          {label}\n        </span>\n        {sublabel != null ? (\n          <span\n            data-slot=\"rank-list-sublabel\"\n            className=\"truncate text-xs leading-snug text-muted-foreground\"\n          >\n            {sublabel}\n          </span>\n        ) : null}\n      </span>\n\n      {value != null ? (\n        <span\n          data-slot=\"rank-list-value\"\n          className=\"relative shrink-0 text-right font-medium tabular-nums whitespace-nowrap text-foreground\"\n        >\n          {value}\n        </span>\n      ) : null}\n    </li>\n  )\n}\n\nexport { RankList, RankListItem, rankListVariants }\nexport type { RankListProps, RankListItemProps }\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}