export function MiniStat({ item }) {
const caption = parseCaption(item.caption);
const deltaTone = item.deltaTone || (caption.delta.startsWith("-") ? "down" : "up");
return (
{item.label}
{item.value}
{caption.label}
{caption.delta ? {`${deltaTone === "down" ? "↓" : "↑"} ${caption.delta.replace(/^[-+]/, "")}`} : null}
);
}
function parseCaption(caption = "") {
const normalized = String(caption).trim().replace(/\s+/g, " ");
const match = normalized.match(/^(.*)\s([+-][\d.]+(?:%|pp)?)$/);
if (!match) {
return { delta: "", label: normalized };
}
return { delta: match[2], label: match[1] };
}
export function TwoMetricRow({ items }) {
return (
{items.map((item) => (
))}
);
}
export function FourMetricRow({ items }) {
return (
{items.map((item) => (
))}
);
}
export function FiveMetricRow({ items }) {
return (
{items.map((item) => (
))}
);
}