{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "empty-state",
  "title": "Empty State",
  "author": "zyx1121 (https://github.com/zyx1121)",
  "description": "One sentence and the next step when a list or a search has no rows, with a table row variant.",
  "registryDependencies": [
    "https://ui.zyx.tw/r/button.json",
    "https://ui.zyx.tw/r/table.json"
  ],
  "files": [
    {
      "path": "registry/zyx/components/empty-state.tsx",
      "content": "import * as React from \"react\"\n\nimport { Button } from \"./ui/button\"\nimport { TableCell, TableRow } from \"./ui/table\"\n\ntype EmptyStateProps = {\n  /** What the list holds, plural: \"receipts\", \"projects\". The sentence is\n   * built from it, so every app says it the same way. */\n  noun: string\n  /** The search that found nothing. Without it the list is simply empty. */\n  query?: string\n  /** Shown with a query: a button that clears it. */\n  onClearQuery?: () => void\n  /** Shown without a query: the action that adds the first one. */\n  action?: React.ReactNode\n}\n\nfunction emptyText(noun: string, query?: string) {\n  return query ? `No ${noun} match “${query}”` : `No ${noun} yet`\n}\n\n// What a list shows when it has no rows: \"No receipts yet\" when there is\n// nothing yet, \"No receipts match “…”\" when a search came up empty.\nfunction EmptyState({ noun, query, onClearQuery, action }: EmptyStateProps) {\n  const next = query\n    ? onClearQuery && (\n        <Button key=\"clear\" variant=\"outline\" onClick={onClearQuery}>\n          Clear search\n        </Button>\n      )\n    : action\n\n  return (\n    <div\n      data-slot=\"empty-state\"\n      className=\"flex flex-col items-center gap-5 py-10 text-center\"\n    >\n      <p className=\"text-muted-foreground\">{emptyText(noun, query)}</p>\n      {next}\n    </div>\n  )\n}\n\ntype TableEmptyProps = Pick<EmptyStateProps, \"noun\" | \"query\"> & {\n  /** The table's column count. */\n  colSpan: number\n}\n\n// The same sentence as one row spanning a table, under its header.\nfunction TableEmpty({ noun, query, colSpan }: TableEmptyProps) {\n  return (\n    <TableRow className=\"hover:bg-transparent\">\n      <TableCell\n        colSpan={colSpan}\n        className=\"py-10 text-center text-muted-foreground\"\n      >\n        {emptyText(noun, query)}\n      </TableCell>\n    </TableRow>\n  )\n}\n\nexport { EmptyState, TableEmpty }\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "useWhen": "A list, table or search with no rows: one sentence and the next step.",
    "notFor": "Errors and missing pages; use status-page.",
    "related": [
      "table",
      "status-page"
    ]
  },
  "docs": "Use when: A list, table or search with no rows: one sentence and the next step.\nNot for: Errors and missing pages; use status-page.\nGuide: https://ui.zyx.tw/empty-state.md",
  "categories": [
    "block",
    "feedback"
  ],
  "type": "registry:block"
}