Stats List Adapter (Mr. Doge SDK)
mrdoge-ui/mrdoge-stats-list-adapterFreeUtility
Maps a real match.stats (any of the 8 sports) onto Stats List's entries prop.
Install it
npx shadcn@latest add https://mrdoge.co/r/mrdoge-stats-list-adapter.jsonSource
1import type { MatchDetail, MatchStats } from "@mrdoge/protocol"2import type { StatsListEntry } from "@/registry/mrdoge-ui/stats-list/stats-list"34function pair(label: string, home: number | undefined, away: number | undefined, format?: (n: number) => string): StatsListEntry | null {5 if (home == null || away == null) return null6 const toText = format ?? String7 return { label, home: toText(home), away: toText(away), homeValue: home, awayValue: away }8}910function percent(value: number) {11 return `${Math.round(value * 100)}%`12}1314// Booleans (who's serving, who's in the bonus) still render as a bar (a15// full bar on whichever side is true, empty on the other) rather than16// being dropped, since every row here is a comparison bar.17function booleanPair(label: string, home: boolean | undefined, away: boolean | undefined): StatsListEntry | null {18 if (home == null && away == null) return null19 return {20 label,21 home: home ? "Yes" : "No",22 away: away ? "Yes" : "No",23 homeValue: home ? 1 : 0,24 awayValue: away ? 1 : 0,25 }26}2728/**29 * Maps a real `match.stats` (from `matches.get()`/`matches.subscribe()`)30 * to Stats List's entries: a plain array, one row per available stat. If31 * the SDK's shape changes, this fails to compile.32 *33 * MatchStats is a discriminated union per sport, so this switches on34 * `stats.sport`. Every branch is covered, but four sports35 * (american football, baseball, ice hockey, handball) currently have no36 * comparable home/away stats in the protocol beyond score and clock37 * (already shown elsewhere, e.g. Match Highlight), so those return an38 * empty array rather than padding the list with fields that don't exist.39 * Tennis's current-game points ("15"/"40"/"AD") aren't included: text,40 * not a number, so there's no meaningful bar for it.41 */42export function statsToStatsListEntries(stats: MatchStats | null | undefined): StatsListEntry[] {43 if (!stats) return []4445 switch (stats.sport) {46 case "soccer":47 return [48 pair("Possession", stats.homePossession, stats.awayPossession, percent),49 pair("Expected Goals", stats.homeExpectedGoals, stats.awayExpectedGoals, (n) => n.toFixed(2)),50 pair("Shots", stats.homeShots, stats.awayShots),51 pair("Shots on Target", stats.homeShotsOnTarget, stats.awayShotsOnTarget),52 pair("Corners", stats.homeCorners, stats.awayCorners),53 pair("Fouls", stats.homeFouls, stats.awayFouls),54 pair("Offsides", stats.homeOffsides, stats.awayOffsides),55// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from mrdoge-ui
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Bet Slip Adapter (Mr. Doge SDK)mrdoge-bet-slip-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Mr. Doge Clientmrdoge-client | mrdoge-ui | Utilities | Free | 1 dep | |
| Conflict Adapter (Mr. Doge SDK)mrdoge-conflict-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Match Card Adapter (Mr. Doge SDK)mrdoge-match-card-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Match Highlight Adapter (Mr. Doge SDK)mrdoge-match-highlight-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Match Timeline Adapter (Mr. Doge SDK)mrdoge-match-timeline-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Odds Selector Adapter (Mr. Doge SDK)mrdoge-odds-selector-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Rate Limitrate-limit | mrdoge-ui | Utilities | Free | no deps |
