{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-card",
  "type": "registry:ui",
  "title": "Chart Card",
  "description": "Chart Card is a Card composed for a chart: an optional title/description/actions header, and a body that owns loading/empty/error presentation around a chart the consumer supplies as children.",
  "author": "Skrewww",
  "dependencies": [],
  "registryDependencies": [
    "@skrewww/card",
    "@skrewww/empty-state",
    "@skrewww/alert",
    "@skrewww/skeleton",
    "@skrewww/foundation"
  ],
  "docs": "Host requirements (assumed already present, not installed by this command): react, react-dom.",
  "files": [
    {
      "path": "components/ui/ChartCard.tsx",
      "content": "/** @skrewww-component chart-card */\nimport type { ReactNode } from \"react\";\nimport { Alert } from \"@/components/ui/Alert\";\nimport { Card, type CardElevation } from \"@/components/ui/Card\";\nimport { EmptyState } from \"@/components/ui/EmptyState\";\nimport { Skeleton } from \"@/components/ui/Skeleton\";\nimport { cn } from \"@/lib/cn\";\nimport styles from \"@/components/ui/chart-card.module.css\";\n\nexport type ChartCardState = \"ready\" | \"loading\" | \"empty\" | \"error\";\n\nexport type ChartCardProps = {\n  title?: string;\n  description?: ReactNode;\n  /** Heading level for the optional title. Defaults to `h3`. */\n  headingLevel?: \"h2\" | \"h3\" | \"h4\";\n  /** Header-right slot — e.g. a time-range Tabs group, a filter Button, or a Menu of chart actions. */\n  actions?: ReactNode;\n  elevation?: CardElevation;\n  /** Which region renders in the body. Defaults to `\"ready\"`. */\n  state?: ChartCardState;\n  /**\n   * Minimum height reserved for the body, in pixels — keeps the card's size\n   * stable across every state (ready/loading/empty/error), matching a\n   * chart's own `height` prop. Real content taller than this still grows\n   * the card; it is a floor, not a fixed box.\n   */\n  contentHeight?: number;\n  loadingLabel?: string;\n  emptyTitle?: string;\n  emptyDescription?: ReactNode;\n  errorTitle?: string;\n  errorDescription?: ReactNode;\n  /** e.g. a \"Retry\" Button, rendered alongside the error message. */\n  errorAction?: ReactNode;\n  /** Rendered only when `state` is `\"ready\"` — typically a `ChartMetric` and a chart. */\n  children?: ReactNode;\n  footer?: ReactNode;\n  className?: string;\n};\n\n/**\n * A Card composed for a chart: an optional title/description/actions header,\n * a body that owns loading/empty/error presentation around consumer-supplied\n * `children`, and Card's own footer. It is a thin composition, not a new\n * visual system — the surface, border, radius, and Shape/Surface behavior\n * are 100% Card's (see Card.tsx); ChartCard adds no background, border, or\n * radius of its own anywhere in its stylesheet.\n *\n * Ownership, stated explicitly (see docs/architecture and the registry\n * openQuestions for the reasoning): a chart family (BarChart/LineChart/\n * AreaChart) never owns network state — it only renders whatever `data` it\n * is given, including an empty array. Fetching, loading, \"no results\", and\n * error presentation belong to the composition around the chart. ChartCard\n * is that composition; it does not fetch anything itself.\n *\n * `children` render only when `state` is `\"ready\"` — put the chart (and an\n * optional `ChartMetric`) there. The `error` region is announced politely\n * (`Alert announce=\"polite\"`) since it represents a state the user was not\n * otherwise told about; loading and empty are not (no error occurred).\n */\nexport function ChartCard({\n  title,\n  description,\n  headingLevel: Heading = \"h3\",\n  actions,\n  elevation,\n  state = \"ready\",\n  contentHeight = 240,\n  loadingLabel = \"Loading chart\",\n  emptyTitle = \"No data\",\n  emptyDescription,\n  errorTitle = \"Couldn't load chart\",\n  errorDescription,\n  errorAction,\n  children,\n  footer,\n  className,\n}: ChartCardProps) {\n  const hasHeader = Boolean(title || description || actions);\n\n  return (\n    <Card elevation={elevation} footer={footer} className={className}>\n      {hasHeader ? (\n        <div className={styles.header}>\n          {title || description ? (\n            <div className={styles.heading}>\n              {title ? <Heading className={styles.title}>{title}</Heading> : null}\n              {description ? <p className={styles.description}>{description}</p> : null}\n            </div>\n          ) : null}\n          {actions ? <div className={styles.actions}>{actions}</div> : null}\n        </div>\n      ) : null}\n      <div className={styles.content} style={{ minHeight: contentHeight }}>\n        {state === \"ready\" ? children : null}\n        {state === \"loading\" ? (\n          <div className={cn(styles.stateBox)} aria-busy=\"true\">\n            <span className=\"sr-only\">{loadingLabel}</span>\n            <Skeleton shape=\"rectangle\" width=\"100%\" height={contentHeight} />\n          </div>\n        ) : null}\n        {state === \"empty\" ? (\n          <div className={styles.stateBox}>\n            <EmptyState title={emptyTitle} description={emptyDescription} className={styles.emptyState} />\n          </div>\n        ) : null}\n        {state === \"error\" ? (\n          <div className={styles.stateBox}>\n            <Alert type=\"error\" title={errorTitle} description={errorDescription} action={errorAction} announce=\"polite\" />\n          </div>\n        ) : null}\n      </div>\n    </Card>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/ChartCard.tsx"
    },
    {
      "path": "components/ui/chart-card.module.css",
      "content": "/*\n * No background/border/radius/Shape/Surface property anywhere in this file:\n * ChartCard renders inside Card's own body, so every surface property\n * (fill, border, radius, Glass/Squircle behavior) already comes from Card's\n * own stylesheet — see Card.tsx / card.module.css and BankingAccountCard's\n * own \"Surface/Shape inheritance\" note, the same mechanism this reuses.\n */\n.header {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: flex-start;\n  justify-content: space-between;\n  gap: 0.75rem;\n  margin-bottom: 0.75rem;\n}\n\n.heading {\n  min-width: 0;\n}\n\n.title {\n  margin: 0;\n  font-size: 1rem;\n  font-weight: 600;\n  line-height: 1.4;\n  color: var(--semantic-text-primary);\n}\n\n.description {\n  margin: 0.25rem 0 0;\n  font-size: 0.8125rem;\n  line-height: 1.4;\n  color: var(--semantic-text-secondary);\n}\n\n.actions {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  gap: 0.5rem;\n  flex: none;\n}\n\n.content {\n  display: flex;\n  flex-direction: column;\n}\n\n.stateBox {\n  display: flex;\n  flex: 1;\n  align-items: center;\n  justify-content: center;\n}\n\n.emptyState {\n  padding: 1.5rem 1rem;\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/chart-card.module.css"
    },
    {
      "path": "lib/cn.ts",
      "content": "export function cn(...classes: Array<string | false | null | undefined>): string {\n  return classes.filter(Boolean).join(\" \");\n}\n",
      "type": "registry:lib",
      "target": "~/lib/cn.ts"
    }
  ]
}
