{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "data-stat-card",
  "type": "registry:component",
  "title": "Statistic / metric cards",
  "description": "A card that shows one derived reading",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/data/src/internal/readable.tsx",
      "target": "@ui/gpuixui/data/internal/readable.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { StyleDesc } from \"@gpuix/react\";\nimport * as P from \"effect/Predicate\";\nimport type { ReactNode } from \"react\";\n\nexport interface ReadableProps {\n  readonly testId?: string;\n  readonly style?: StyleDesc;\n}\n\nexport const readable = (\n  value: ReactNode,\n  { testId, style }: ReadableProps = {},\n) =>\n  P.isString(value) || P.isNumber(value) ? (\n    <text testId={testId} style={style}>\n      {value}\n    </text>\n  ) : (\n    <div testId={testId} style={style}>\n      {value}\n    </div>\n  );\n"
    },
    {
      "path": "packages/data/src/recipe.ts",
      "target": "@ui/gpuixui/data/recipe.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { createRecipeCache } from \"../tw/index.js\";\nimport type { Theme } from \"./theme.js\";\n\nexport const recipeStyle: (recipe: string, theme: Theme) => StyleDesc =\n  createRecipeCache(256);\n"
    },
    {
      "path": "packages/data/src/surfaces/recipe.ts",
      "target": "@ui/gpuixui/data/surfaces/recipe.ts",
      "type": "registry:lib",
      "content": "export const SURFACE_PANEL =\n  \"flex flex-col rounded-lg border border-input bg-card text-foreground\";\n\nexport const SURFACE_HEADER =\n  \"flex flex-row items-center justify-between gap-2 border-b border-input px-3 py-2\";\n\nexport const KEY_VALUE_ROW = \"flex flex-row items-center gap-2 py-1\";\n\nexport const KEY_VALUE_LABEL = \"text-xs text-muted-foreground\";\n\nexport const KEY_VALUE_VALUE = \"text-xs text-foreground\";\n\nexport const STAT_CARD =\n  \"flex flex-col gap-1 rounded-lg border border-input bg-card px-3 py-2\";\n\nexport const STAT_VALUE = \"text-2xl font-semibold text-foreground\";\n\nexport const STAT_LABEL = \"text-xs text-muted-foreground\";\n\nexport const STAT_HINT = \"text-xs text-muted-foreground\";\n\nexport const DATA_TOOLBAR =\n  \"flex flex-row items-center gap-2 rounded-md border border-input bg-muted px-2 py-1\";\n\nexport const FILTER_CLAUSE = \"flex flex-row items-center gap-2 py-1\";\n\nexport const FILTER_GROUP = \"flex flex-col gap-1 border-l border-input pl-2\";\n\nexport const ADVANCED_FILTER =\n  \"flex flex-col gap-2 rounded-lg border border-input bg-card px-3 py-2\";\n\nexport const FILTER_SENTENCE = \"text-xs text-foreground\";\n"
    },
    {
      "path": "packages/data/src/surfaces/stat-card.tsx",
      "target": "@ui/gpuixui/data/surfaces/stat-card.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props } from \"@gpuix/react\";\nimport { mergeStyles } from \"@gpuix/react/floating\";\nimport { spaceValue, visibleCopy } from \"../../primitives/core/index.js\";\nimport { statusTone } from \"../../tokens/index.js\";\nimport { cn } from \"../../tw/index.js\";\nimport * as Option from \"effect/Option\";\nimport * as P from \"effect/Predicate\";\nimport type { ReactNode } from \"react\";\nimport { readable } from \"../internal/readable.js\";\nimport { recipeStyle } from \"../recipe.js\";\nimport { themeColors, useTheme } from \"../theme.js\";\nimport { STAT_CARD, STAT_HINT, STAT_LABEL, STAT_VALUE } from \"./recipe.js\";\n\nexport interface StatTrend {\n  readonly direction: \"up\" | \"down\" | \"flat\";\n\n  readonly text: string | null;\n}\n\nexport interface StatCardProps extends Omit<Props, \"children\"> {\n  readonly label: string;\n\n  readonly value: ReactNode;\n\n  readonly unit?: string;\n\n  readonly hint?: ReactNode;\n\n  readonly trend?: StatTrend;\n  readonly className?: string;\n}\n\nexport const trendTone = (\n  direction: StatTrend[\"direction\"],\n  theme: ReturnType<typeof useTheme>,\n): string | undefined =>\n  direction === \"up\"\n    ? statusTone(theme, \"success\").foreground\n    : direction === \"down\"\n      ? statusTone(theme, \"destructive\").foreground\n      : themeColors(theme).mutedForeground;\n\nexport const StatCard = ({\n  label,\n  value,\n  unit,\n  hint,\n  trend,\n  className,\n  style,\n  ...rest\n}: StatCardProps) => {\n  const theme = useTheme();\n\n  const movement = Option.fromNullishOr(trend);\n\n  const title = visibleCopy(label);\n  const unitCopy = visibleCopy(unit);\n  const hintCopy = P.isString(hint) ? visibleCopy(hint) : hint;\n  return (\n    <div\n      {...rest}\n      role=\"group\"\n      style={mergeStyles(recipeStyle(cn(STAT_CARD, className), theme), style)}\n    >\n      {title === undefined ? undefined : (\n        <text style={recipeStyle(STAT_LABEL, theme)}>{title}</text>\n      )}\n      <div\n        style={{\n          display: \"flex\",\n          flexDirection: \"row\",\n          alignItems: \"baseline\",\n          gap: spaceValue(theme, \"xs\"),\n        }}\n      >\n        {readable(value, { style: recipeStyle(STAT_VALUE, theme) })}\n        {unitCopy === undefined ? undefined : (\n          <text style={recipeStyle(STAT_HINT, theme)}>{unitCopy}</text>\n        )}\n        {Option.match(movement, {\n          onNone: () => undefined,\n          onSome: (shown) => {\n            const words = visibleCopy(shown.text ?? undefined);\n            return words === undefined ? undefined : (\n              <text\n                style={{\n                  ...recipeStyle(STAT_HINT, theme),\n                  color: trendTone(shown.direction, theme),\n                }}\n              >\n                {words}\n              </text>\n            );\n          },\n        })}\n      </div>\n      {hintCopy === undefined\n        ? undefined\n        : readable(hintCopy, { style: recipeStyle(STAT_HINT, theme) })}\n    </div>\n  );\n};\n"
    },
    {
      "path": "packages/data/src/theme.ts",
      "target": "@ui/gpuixui/data/theme.ts",
      "type": "registry:lib",
      "content": "import type { Theme } from \"../tokens/index.js\";\nimport { useTheme as useTokenTheme } from \"../tokens/react.js\";\n\nexport {\n  controlFocusRing,\n  dividerOn,\n  pointerWash,\n  textStyle,\n  themeColors,\n} from \"../tokens/index.js\";\nexport type { Theme };\n\nexport const useTheme = (): Theme => useTokenTheme();\n"
    }
  ],
  "docs": "[Statistic / metric cards](https://gpuixui.sudokw.com/data-display/stat-card) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/data-display/stat-card",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}