{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kpi-tile",
  "type": "registry:component",
  "title": "KPI tile",
  "description": "A headline number with its comparison, direction-aware colour and an optional sparkline.",
  "dependencies": [],
  "registryDependencies": [
    "https://chartslibraryui.com/r/core.json",
    "https://chartslibraryui.com/r/sparkline.json"
  ],
  "files": [
    {
      "path": "registry/charts/kpi-tile.tsx",
      "type": "registry:component",
      "target": "components/charts/kpi-tile.tsx",
      "content": "\"use client\";\n// kpi-tile.tsx · ChartslibraryUI 1.1.0 · MIT License · https://chartslibraryui.com\n\nimport type { ReactNode } from \"react\";\nimport { arrowGlyph, toneOf, toneText, toneWord, type Favorable } from \"./core/color\";\nimport { formatChange, formatDelta, formatValue, type FormatInput } from \"./core/format\";\nimport { Sparkline } from \"./sparkline\";\nimport { useWords, type ChartWords } from \"./core/words\";\n\nexport interface KpiTileProps {\n  /** Translate the tile's own words (\"Forecast\", \"Partial\"). See ChartWordsProvider. */\n  words?: Partial<ChartWords>;\n  /** Sentence case, no trailing colon: \"Annual recurring revenue\". */\n  label: string;\n  /** The headline number. null or undefined shows a missing value, never 0. */\n  value: number | null | undefined;\n  /** Number format for values: \"currency\", \"percent\", \"integer\", \"compact\" or a format object. */\n  format?: FormatInput;\n  /** Comparison value (prior period, plan, target). */\n  compare?: number | null;\n  /** Names the comparison: \"vs last year\", \"vs plan\". */\n  compareLabel?: string;\n  /** Is up good? \"down\" for costs, churn, latency. Default \"up\". */\n  favorable?: Favorable;\n  /** How to express the change. Default: \"both\" for currency/number, \"absolute\" (pp) for percentages. */\n  delta?: \"absolute\" | \"relative\" | \"both\" | \"none\";\n  /** Optional trend, oldest first. */\n  trend?: (number | null)[];\n  /** Extra line under the delta (e.g. \"Target $20M\"). */\n  footnote?: ReactNode;\n  /** Extra class names on the chart's outer element. */\n  className?: string;\n  /** Mark the value as a forecast or partial period. */\n  status?: \"forecast\" | \"partial\";\n}\n\n/**\n * A headline number with its comparison. The arrow follows the sign; the colour follows `favorable`, and the\n * accessible text says \"favorable\" or \"unfavorable\" so meaning never depends on colour alone.\n */\nexport function KpiTile({\n  label,\n  value,\n  format,\n  compare,\n  compareLabel = \"vs prior period\",\n  favorable = \"up\",\n  delta: deltaMode,\n  trend,\n  footnote,\n  className,\n  status,\n  words,\n}: KpiTileProps) {\n  const L = useWords(words);\n  const isPercent = typeof format === \"object\" ? format.kind === \"percent\" : format === \"percent\";\n  const mode = deltaMode ?? (isPercent ? \"absolute\" : \"both\");\n  const hasCompare = typeof compare === \"number\" && Number.isFinite(compare) && typeof value === \"number\";\n  const diff = hasCompare ? (value as number) - (compare as number) : null;\n  const tone = toneOf(diff, favorable);\n  const abs = formatDelta(diff, format);\n  const rel = hasCompare ? formatChange(value, compare) : \"–\";\n  const deltaText =\n    mode === \"absolute\" ? abs : mode === \"relative\" ? rel : mode === \"both\" ? (rel === \"–\" ? abs : `${abs} (${rel})`) : \"\";\n  const valueText = formatValue(value, format, { context: \"label\" });\n  const sr = `${label}: ${valueText}${status ? ` (${status})` : \"\"}.${\n    hasCompare && mode !== \"none\" ? ` ${deltaText} ${compareLabel}, ${toneWord(tone)}.` : \"\"\n  }`;\n\n  return (\n    <div className={[\"clui clui-kpi\", className].filter(Boolean).join(\" \")} role=\"group\" aria-label={sr}>\n      <div className=\"clui-kpi-label\" title={label}>\n        {label}\n        {status && <span style={{ marginLeft: 6, color: \"var(--clui-ink-3)\" }}>· {status === \"forecast\" ? L.forecast : L.partial}</span>}\n      </div>\n      <div className=\"clui-kpi-foot\">\n        <div style={{ minWidth: 0 }}>\n          <div className=\"clui-kpi-value\" aria-hidden>\n            {valueText}\n          </div>\n          {hasCompare && mode !== \"none\" && (\n            <div className=\"clui-kpi-delta\" aria-hidden>\n              <span style={{ color: toneText(tone), fontWeight: 500 }}>\n                {arrowGlyph(diff) && <span style={{ fontSize: 9, marginRight: 3 }}>{arrowGlyph(diff)}</span>}\n                {deltaText}\n              </span>\n              <span className=\"clui-kpi-delta-muted\">{compareLabel}</span>\n            </div>\n          )}\n        </div>\n        {trend && trend.length > 1 && (\n          <div className=\"clui-kpi-spark\" style={{ width: 84, flexShrink: 0 }} aria-hidden>\n            <Sparkline data={trend} height={30} format={format} label={label} />\n          </div>\n        )}\n      </div>\n      {footnote && <div className=\"clui-kpi-delta clui-kpi-delta-muted\">{footnote}</div>}\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "tier": "free",
    "category": "kpi",
    "component": "KpiTile"
  }
}