{
"files": [
{
"content": "defmodule Shadix.Components.Table do\n @moduledoc \"\"\"\n A responsive table component, translated from shadcn/ui.\n\n Provides `table/1` (wrapped in a scroll container) along with\n `table_header/1`, `table_body/1`, `table_footer/1`, `table_row/1`,\n `table_head/1`, `table_cell/1`, and `table_caption/1`.\n \"\"\"\n use Phoenix.Component\n import Shadix.Cn\n\n @table \"w-full caption-bottom text-sm\"\n @table_header \"[&_tr]:border-b\"\n @table_body \"[&_tr:last-child]:border-0\"\n @table_footer \"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0\"\n @table_row \"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted\"\n @table_head \"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]\"\n @table_cell \"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]\"\n @table_caption \"mt-4 text-sm text-muted-foreground\"\n\n attr(:class, :string, default: nil)\n attr(:rest, :global)\n slot(:inner_block, required: true)\n\n def table(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table, assigns.class]))\n\n ~H\"\"\"\n <div data-slot=\"table-container\" class=\"relative w-full overflow-x-auto\">\n <table data-slot=\"table\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </table>\n </div>\n \"\"\"\n end\n\n attr(:class, :string, default: nil)\n attr(:rest, :global)\n slot(:inner_block, required: true)\n\n def table_header(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table_header, assigns.class]))\n\n ~H\"\"\"\n <thead data-slot=\"table-header\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </thead>\n \"\"\"\n end\n\n attr(:class, :string, default: nil)\n attr(:rest, :global)\n slot(:inner_block, required: true)\n\n def table_body(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table_body, assigns.class]))\n\n ~H\"\"\"\n <tbody data-slot=\"table-body\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </tbody>\n \"\"\"\n end\n\n attr(:class, :string, default: nil)\n attr(:rest, :global)\n slot(:inner_block, required: true)\n\n def table_footer(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table_footer, assigns.class]))\n\n ~H\"\"\"\n <tfoot data-slot=\"table-footer\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </tfoot>\n \"\"\"\n end\n\n attr(:class, :string, default: nil)\n attr(:rest, :global, include: ~w(data-state))\n slot(:inner_block, required: true)\n\n def table_row(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table_row, assigns.class]))\n\n ~H\"\"\"\n <tr data-slot=\"table-row\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </tr>\n \"\"\"\n end\n\n attr(:class, :string, default: nil)\n attr(:rest, :global, include: ~w(colspan rowspan scope abbr))\n slot(:inner_block, required: true)\n\n def table_head(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table_head, assigns.class]))\n\n ~H\"\"\"\n <th data-slot=\"table-head\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </th>\n \"\"\"\n end\n\n attr(:class, :string, default: nil)\n attr(:rest, :global, include: ~w(colspan rowspan headers))\n slot(:inner_block, required: true)\n\n def table_cell(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table_cell, assigns.class]))\n\n ~H\"\"\"\n <td data-slot=\"table-cell\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </td>\n \"\"\"\n end\n\n attr(:class, :string, default: nil)\n attr(:rest, :global)\n slot(:inner_block, required: true)\n\n def table_caption(assigns) do\n assigns = assign(assigns, :computed_class, cn([@table_caption, assigns.class]))\n\n ~H\"\"\"\n <caption data-slot=\"table-caption\" class={@computed_class} {@rest}>\n {render_slot(@inner_block)}\n </caption>\n \"\"\"\n end\nend\n",
"path": "table.ex"
}
],
"hooks": [],
"name": "table",
"npm_deps": [],
"registry_deps": [
"cn"
]
}